1.9 KiB
1.9 KiB
type, title, description, tags, status, generated
| type | title | description | tags | status | generated | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Service | Gateway | The only public service; serves the static site, streams chapter states over SSE, and forwards rate-limited knockdowns. |
|
stable |
|
Routes
| Route | Does |
|---|---|
GET / and static paths |
Serves the Nuxt build, embedded with go:embed |
GET /api/events |
SSE stream: full state on connect, then each change |
POST /api/fall/{chapter} |
Allowlist, cooldown, rate limit, then calls the chapter's /fall |
Reading cluster state
- v1 polls
list podsandlist eventsincvevery 2 seconds and diffs the result. At about 10 pods this is cheap. Upgrade path: a client-go informer. - Recovery times come from the pod's Ready condition
lastTransitionTime, so they are exact even though polling is not. - Dependency:
k8s.io/client-go. It authenticates through the in-cluster ServiceAccount.
SSE event shape
{"chapter": "example", "phase": "Running", "ready": true, "restarts": 3, "event": "recovered", "seconds": 4.2}
The same stream feeds the life map and the developer view.
Limits
- Per-chapter cooldown: a
map[string]time.Timebehind a mutex. Default 30 seconds. - Global limit:
golang.org/x/time/rate, for example 1 fall per second with burst 3. - Knockdowns are shared state on purpose: every viewer sees "someone just knocked down X".
Cloudflare Tunnel and SSE
- Send
Content-Type: text/event-streamand flush after every message. - Send a comment line (
: ping) every 30 seconds so idle connections are not closed.
Resources
64Mi memory limit with GOMEMLIMIT=50MiB, 100m CPU. See server budget.
RBAC
ServiceAccount gateway in cv, Role with get/list/watch on pods,
events and jobs. No create, delete or patch.