internal gateway: single serving address (siriussec only) + a probe that notices when it flaps

rpi carried node-role.kubernetes.io/gateway=true, so cilium-envoy bound 8080/8081/8084
there too. Its Envoy completes TCP to a backend pod on siriussec but never finishes
the request: every hit on 10.10.0.1:8081/8084 hung 5s and returned 503, even from the
Pi own 127.0.0.1, while 10.10.0.2 answered in ms. Clients that tried either address
saw the dashboards flap. Remove the label from rpi: one gateway node, one address.

The Gateway status.addresses still lists every node InternalIP (cilium#29060 ignores
spec.addresses) - it is not a VIP; only 10.10.0.2 serves.

Add blackbox-exporter + Probe (8081, 8084 every 30s) + PrometheusRule alerts so a
regression is visible in the stack instead of on a phone. Give the internal_gw nft
accept rules counters so an allowed request is provable.
This commit is contained in:
Lance Walters 2026-10-27 00:57:39 -04:00
commit 48b2b6ac01
4 changed files with 205 additions and 20 deletions

View file

@ -23,12 +23,14 @@ Related: [[Home-Lab-Kubernetes-Cluster]], `docs/cluster-overview.md`,
Cilium's Gateway implementation runs **one hostNetwork Envoy per gateway node**
(`cilium-envoy` DaemonSet, node selector `node-role.kubernetes.io/gateway=true`
— currently `rpi` 10.10.0.1 and `siriussec` 10.10.0.2) and binds **every**
— **`siriussec` 10.10.0.2 only**, since 2026-10-27) and binds **every**
listener port on `0.0.0.0`. There is no Gateway API field for "listen on wg0
only". Consequences:
- A listener on port 8081 is reachable on `192.168.1.125:8081`,
`192.168.1.179:8081` and the public interface the moment it is Programmed.
- A listener on port 8081 is reachable on `192.168.1.179:8081` (siriussec's
LAN address) and on siriussec's WG address the moment it is Programmed.
Nothing binds `:8081` on rpi: it lost the `gateway=true` label on 2026-10-27,
so `10.10.0.1:8081` is a **closed port**, not a second origin.
- The Gateway object cannot enforce the network boundary. **The host firewall
is the enforcement point.** That is the whole trick.
- The service is reached as **`http://10.10.0.2:<port>/`** — no `/etc/hosts`
@ -59,13 +61,14 @@ tunnel, whose ingress list is an explicit allow-list of hostnames pointing at
| `Gateway internal/internal` | `infrastructure/networking/internal/gateway.yaml` (Flux: `infrastructure`) | listener `http-internal`, **port 8081**, `allowedRoutes: All` so any namespace can attach. **One bare-IP service only** (Grafana) — see the merge gotcha above |
| `Gateway internal/hubble-ui` | `infrastructure/networking/internal/gateway-hubble-ui.yaml` | listener `http-internal`, **port 8084**, its own RouteConfiguration, so its hostname-less route cannot merge with Grafana's |
| `HTTPRoute <svc>` | the app's own tree (e.g. `monitoring/controllers/home/httproute.yaml`, `infrastructure/networking/cilium/hubble-ui-httproute.yaml`) | `parentRefs: <gateway>/internal#http-internal`, **no `hostnames`** |
| `table inet internal_gw` + `internal-gw-firewall.service` | siriussec host (`/etc/nftables.d/internal-gw.nft`) | drop `:8081`+`:8084` from everything but `10.10.0.0/24`, `10.244.0.0/16`, `lo` |
| ufw rules (inserted above the LAN catch-all) | rpi host | same policy for `:8081`+`:8084` |
| `infrastructure/networking/internal/host-firewall/` | repo | the two host artifacts + install/verify instructions |
| `table inet internal_gw` + `internal-gw-firewall.service` | siriussec host (`/etc/nftables.d/internal-gw.nft`) | drop `:8081`+`:8084` from everything but `10.10.0.0/24`, `10.244.0.0/16`, `lo`; the accept rules carry `counter`s so "traffic arrived and was allowed" is provable, not inferred from a 200 |
| ufw rules (inserted above the LAN catch-all) | rpi host | **inert since 2026-10-27** — left in place as a belt-and-braces guard in case the Pi is ever relabelled `gateway=true`, but nothing binds those ports on rpi any more, so they just make stale `10.10.0.1:8081` clients time out instead of being refused |
| `infrastructure/networking/internal/host-firewall/` | repo | the host artifacts + install/verify instructions |
Both firewalls must be in place: Envoy listens on **both** gateway nodes, so
leaving either node's port open leaks the service to the LAN from that node's
address (and the other node answers 503, which still proves a listener exists).
Only siriussec runs `cilium-envoy`, so only its `internal_gw` table is load
bearing. **If a second node is ever given `gateway=true`**, it needs the same
firewall rules *and* its backends co-located, or it will serve 503s for
everything (see §7).
## 3. Current internal services
@ -79,11 +82,20 @@ address (and the other node answers 503, which still proves a listener exists).
because phones cannot edit `/etc/hosts`. The bare-IP URL is the one to hand
out; the named URL is a convenience for machines that already have the line.
Always use **siriussec's** address (`10.10.0.2`), not the Pi's: Envoy on a node
that does not run the backend pods completes the TCP handshake and then hangs
(SYN-ACK back, no ACK — see the co-location pitfall in the `home-k8s` skill).
The backends are pinned to siriussec, so 10.10.0.2 is the only origin that
works.
**`10.10.0.2` is the only serving address.** The Gateways' `status.addresses`
lists *every* node InternalIP (`10.10.0.1`, `10.10.0.2`, `10.10.0.5`) regardless
of which nodes run `cilium-envoy`, and Cilium ignores `spec.addresses`
(cilium#29060), so the status list is **not** a load-balanced VIP and not a
"try either IP" guide. `10.10.0.1` and `10.10.0.5` have no listener;
`10.10.0.1` times out (ufw DROP), `10.10.0.5` is reachable only as a mesh
address. Hand out the bare-IP URL on 10.10.0.2 and nothing else.
Historical note (fixed 2026-10-27): while rpi carried `gateway=true` its Envoy
completed the TCP handshake but could never finish a request to a backend pod
on siriussec — every request to `10.10.0.1:8081`/`:8084` hung 5 s and returned
**503**, *including from the Pi's own `127.0.0.1`*. That is the co-location
fault (SYN-ACK back, no ACK on `reserved:ingress`), and it is why the label now
lives on siriussec alone.
## 4. Add the next internal service
@ -220,10 +232,21 @@ curl -sS -o /dev/null -w '%{http_code}\n' -H 'Host: forgejo.siriusdevops.com' ht
restart; Cilium reconciles the route table. Changing the **listener** (port,
protocol) does need the `cilium-envoy` pods restarted
(`kubectl -n kube-system delete pod -l k8s-app=cilium-envoy`).
- Envoy on both nodes answers for the listener. If a request to
`10.10.0.1:8081` hangs for ~5 s and returns 503 while `10.10.0.2:8081` is
instant, that is the co-location fault (backend not on that node), not a
firewall or routing problem.
- **Only `siriussec` carries `node-role.kubernetes.io/gateway=true`.** Keep it
that way: `kubectl get nodes -l node-role.kubernetes.io/gateway=true` must
return exactly one node. A 503-after-exactly-5.0 s on a node's own IP (even
`127.0.0.1`) means Envoy is running there but the backend pod is not on that
node — remove the label rather than firewalling around it. Removing the label
deletes the `cilium-envoy` DaemonSet pod on that node within seconds and the
ports go with it; no restart of the remaining pod is needed (the Gateway
object is unchanged).
- **The probe in `monitoring/controllers/home/gateway-probe.yaml` is the flap
detector**: blackbox-exporter + a `Probe` for `http://10.10.0.2:8081/` and
`:8084/` every 30 s, alerting `InternalGatewayUnreachable`
(`probe_success == 0` for 3 min) and `InternalGatewayProbeMissing`
(`absent()`) as a `PrometheusRule`. Watch it in Prometheus `/alerts` or
Grafana → Alerting. There is no Alertmanager in the stack yet, so nothing is
*paged*; the alert is visible, not pushed.
## 8. Verification log — 2026-10-27 (Grafana)