---
id: w1/m4/t004
title: Traefik routing — sleeping app → activator/interceptor
worker: worker1
status: done
estimate: 30m
depends_on: [w1/m4/t003]
---

## Objective

Route traffic for a sleeping (0-replica) app to the activator instead of the empty Service.

## Implementation

No separate Traefik config needed — the operator already controls the `networking.k8s.io/Ingress` for each App. When `autoHibernating` is true:

- `ingressSvc = r.ActivatorService` (e.g. `"bex-activator"`)
- `ingressPort = int32(r.ActivatorPort)` (e.g. `8888`)

The Ingress backend flips from `{app.Name: port}` to `{bex-activator: 8888}`. Traefik picks up the Ingress change immediately. When the app wakes, the operator reconciles and flips the backend back.

**k8s manifests**: `lego/operator/config/activator/` — Deployment, Service, ServiceAccount, Role, RoleBinding, kustomization.yaml. The activator runs in `bex-system` (same namespace as App Ingresses) so Ingress backend references resolve.

**Operator wiring**:
- `AppReconciler.ActivatorService` — from `BEX_ACTIVATOR_SERVICE` env; empty = feature off.
- `AppReconciler.ActivatorPort` — from `BEX_ACTIVATOR_PORT` env (default 8888).
