Live pods on the page, and which one is serving you
What
demo.hoortrend.com now shows the pods, live, and which one is serving you.
- New section "The pods, live": one card per running copy (pod, node, version, uptime, requests served). The page
asks
/api/podsevery 2 seconds; each request goes through the Ingress, which picks a pod, and the pod that answered is highlighted ("you are here"), with "your requests" counted per pod. A pod that disappears (rollout) is greyed out, a new one appears. -
GET /api/pods: every running copy +served_by.GET /api/self: this pod's facts, not counted. - Discovery without the Kubernetes API: the headless Service
demo-app-peersreturns one DNS record per ready pod; each pod asks the others directly. Answers are type-checked, cached one second, at most 20 peers. - NetworkPolicy: egress was empty; it now allows only DNS (NodeLocal DNS, CoreDNS) and the other demo-app pods on 8080. Checked in the cluster: DNS returns both pods, both answer, the Internet stays blocked.
- CSP:
script-src 'self'; connect-src 'self'for the one external script (/app.js), nothing inline.
Tests
14 unit tests (4 new: /api/self not counted, /api/pods with its own line never stale, peers found by DNS with bad
answers dropped, script and CSP). Browser, two copies behind a round-robin proxy standing in for the Ingress: the
highlight alternates between the two pods, counters right, FR and EN, 390 px without overflow, no console error.
Deploy
NetworkPolicy and headless Service already applied (the current image ignores them). After merge:
kubectl apply -f k8s/10-deployment.yaml adds PEERS; the pipeline rolls out the image.