docs(internal gateway): the flap was rpi being a second, broken gateway node

503 after exactly 5.000s, including from the Pi own 127.0.0.1 - not a stuck
listener. Envoy config dump shows identical listeners on both nodes, so the
fault was node placement, not config. Label removed from rpi: one gateway node.

Record the three-vantage-point matrix, the nft accept counters, the blackbox
Probe/PrometheusRule and the four negatives.
This commit is contained in:
Lance Walters 2026-10-27 01:06:40 -04:00
commit b2d63270be

View file

@ -5,7 +5,7 @@ updated: 2026-10-27
author: Lance Walters (written with Hermes devops agent) author: Lance Walters (written with Hermes devops agent)
tags: [homelab, kubernetes, wireguard, cilium, gateway-api, observability] tags: [homelab, kubernetes, wireguard, cilium, gateway-api, observability]
status: current status: current
verified: 2026-10-27T04:50Z verified: 2026-10-27T05:20Z
--- ---
# Internal (WireGuard-only) services # Internal (WireGuard-only) services
@ -430,12 +430,13 @@ kubectl -n kube-system get pods -l k8s-app=cilium-envoy # both 1/1, RESTARTS 0
logs <rpi pod> --since=60s | grep -c 'cannot bind' # 0 logs <rpi pod> --since=60s | grep -c 'cannot bind' # 0
``` ```
**Only `10.10.0.2` answers.** `10.10.0.1:8081` and `10.10.0.1:8084` both return **Only `10.10.0.2` answers.** As of 2026-10-27 that is true structurally, not
**503 after exactly 5 s from rpi itself** and time out over the mesh — Envoy on a just in practice: `10.10.0.1:8081/:8084` have **no listener** (rpi lost
node that does not run the backend completes the TCP handshake and never ACKs `gateway=true` — see §12); before the fix they returned **503 after exactly
(the same co-location fault as the public gateway). The Gateway status lists 5 s, even from rpi's own `127.0.0.1`**, because Envoy on a node that does not
both node addresses because the class schedules on every `gateway=true` node; run the backend completes the TCP handshake and never ACKs. The Gateway status
the working address is the one the backends are pinned to, `10.10.0.2`. still lists all three node addresses (Cilium ignores `spec.addresses`); the
serving address is the one the backends are pinned to, `10.10.0.2`.
## 11. Internal DNS: the `lab.internal` zone ## 11. Internal DNS: the `lab.internal` zone
@ -644,3 +645,135 @@ touched).
was brought up by hand — a hard dependency would fail the boot). `bind-dynamic` was brought up by hand — a hard dependency would fail the boot). `bind-dynamic`
picks up `wg0`/`wg-remote` whenever they appear. Records and the bind list live picks up `wg0`/`wg-remote` whenever they appear. Records and the bind list live
in `/etc/dnsmasq*`, not in `/run`; ufw rules are persistent. in `/etc/dnsmasq*`, not in `/run`; ufw rules are persistent.
## 12. Verification log — 2026-10-27 (the flap: rpi was a second, broken gateway node)
Symptom Lance saw: the internal dashboards "work / don't work" from his phone,
while they were rock-steady from a laptop. Nothing was flapping at 10.10.0.2 —
the flapping address was **10.10.0.1**.
**Root cause.** rpi carried `node-role.kubernetes.io/gateway=true` alongside
siriussec, so `cilium-envoy` ran there and bound `0.0.0.0:8080/8081/8084`. Its
Envoy completes TCP to a backend pod on siriussec but never finishes the
request (SYN-ACK back, no ACK on `reserved:ingress`), so every request on the Pi
hung and then failed. Fixed by removing the label: **one gateway node, one
serving address.**
**Premise corrected — the Pi's listener was not "bound but unresponsive".** A
4 s `curl` timeout made it look like a dead socket; the socket is fine and
answers. The exact shape of the failure is a **503 after 5.000 s**, which is the
upstream-connect timeout, not a stuck accept loop (`ss -lnt` Recv-Q 0, backlog
never filled):
```
# on rpi, before the fix
$ curl -s -o /dev/null -m 15 -w '%{http_code} %{time_total}\n' http://127.0.0.1:8081/
503 5.003515
$ curl -s -o /dev/null -m 15 -w '%{http_code} %{time_total}\n' http://127.0.0.1:8084/
503 5.003963
$ curl -s -o /dev/null -m 15 -w '%{http_code} %{time_total}\n' http://10.10.0.1:8081/
503 5.000658
```
**Envoy's own config (admin unix socket), pre-fix** — all three listeners are
identical in shape, which rules out a per-listener config fault:
```
$ sudo curl -s --unix-socket /var/run/cilium/envoy/sockets/admin.sock \
http://localhost/config_dump
LISTENER internal/cilium-gateway-hubble-ui/listener addr={'address': '0.0.0.0', 'port_value': 8084}
LISTENER gateway-system/cilium-gateway-public/listener addr={'address': '0.0.0.0', 'port_value': 8080}
LISTENER internal/cilium-gateway-internal/listener addr={'address': '0.0.0.0', 'port_value': 8081}
transparent=None use_original_dst=None
listener_filters=['envoy.filters.listener.tls_inspector', 'cilium.bpf_metadata']
FC match: {"transport_protocol": "raw_buffer"} # no per-address filter chains
```
Killed hypotheses: no `original_dst` / address-scoped filter chains (so the
destination IP is irrelevant — that is why `127.0.0.1` failed the same way), no
missing bind, no firewall. What differed was **which node the Envoy pod ran on**.
```
# the fix: exactly one node carries the label
$ kubectl label node rpi node-role.kubernetes.io/gateway-
node/rpi unlabeled
$ kubectl get nodes -l node-role.kubernetes.io/gateway=true -o name
node/siriussec
$ kubectl -n kube-system get pods -l k8s-app=cilium-envoy -o wide
cilium-envoy-xfkfq 1/1 Running 0 10.10.0.2 siriussec # the rpi pod is gone
```
`Gateway.status.addresses` still lists `10.10.0.1 10.10.0.2 10.10.0.5` (every
node InternalIP) and Cilium ignores `spec.addresses` (cilium#29060), so that
field is not a VIP and not a "try either IP" list. Also note the Pi's ufw accept
rules never showed a packet counter while requests to `10.10.0.1:8081` *were*
reaching Envoy (proved by the 503 body) — `ufw status` does not expose counters,
and "0 packets" there is not evidence the packet never arrived.
**Matrix after the fix** (`curl -m 6`, code + seconds):
| Vantage point | 10.10.0.1:8081 | 10.10.0.1:8084 | 10.10.0.2:8081 | 10.10.0.2:8084 |
|---|---|---|---|---|
| Legion over WG (10.20.0.5 → mesh) | 000 (6.00, ufw DROP) | 000 (6.00) | **302** (0.11) | **200** (0.11) |
| rpi itself, `10.10.0.1` | 000 (0.0002, no listener) | 000 (0.0002) | **302** (0.003) | **200** (0.002) |
| rpi itself, `127.0.0.1` | 000 (0.0002, no listener) | 000 (0.0002) | — | — |
| pod on siriussec (10.244.0.118) | 000 (0.0006) | 000 (0.0007) | **302** (0.001) | **200** (0.001) |
`sudo ss -lntH` on rpi: **0** sockets on 8081/8084 (was 4 + 4, reuseport).
**Firewall counters — the working path is provably accepted, not just "no
error"** (the accept rules now carry `counter`):
```
$ curl http://10.10.0.2:8081/ ; curl http://10.10.0.2:8084/ # from Legion, a pod, and locally on siriussec
$ sudo nft list table inet internal_gw # on siriussec
tcp dport { 8081, 8084 } iifname "lo" counter packets 48 bytes 3200 accept
tcp dport { 8081, 8084 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter packets 948 bytes 164449 accept
tcp dport { 8081, 8084 } counter packets 17 bytes 1020 drop # LAN attempts
```
**Flap detection** — `monitoring/controllers/home/gateway-probe.yaml`
(blackbox-exporter on siriussec + a `Probe` every 30 s + `PrometheusRule`
`InternalGatewayUnreachable` / `InternalGatewayProbeMissing`):
```
$ kubectl -n flux-system get kustomization monitoring -o jsonpath='{.status.lastAppliedRevision}'
master@sha1:48b2b6a...
$ kubectl -n monitoring get pods | grep blackbox
blackbox-exporter-78b95b789c-b4gl8 1/1 Running
$ # /api/v1/targets (Prometheus, port-forward)
probe/monitoring/internal-gateway http://10.10.0.2:8081/ up
probe/monitoring/internal-gateway http://10.10.0.2:8084/ up
probe_success{job="internal-gateway"} 1, 1
# it also caught a real flap while this card was being verified: the concurrent
# Grafana-persistence card recreated the pod and 8081 answered 503 for ~25 s.
# Negative proof of the detector: a third target pointed at the (dead)
# 10.10.0.1:8081 produced probe_success 0 and
# ALERTS{alertname="InternalGatewayUnreachable",alertstate="pending",
# instance="http://10.10.0.1:8081/"} = 1
# (state cleared when Flux re-applied the Probe from git before `for: 3m`
# elapsed, so `firing` was not observed end-to-end).
```
There is **no Alertmanager** in the stack, so this is visible in Prometheus
`/alerts` and Grafana → Alerting, not paged. Next step if a page is wanted: add
a contact point/receiver, not another probe.
**Negatives re-proved after the change**
```
# LAN (from Legion, 192.168.1.0/24) — DROP on both nodes, both ports
192.168.1.179:8081 -> 000 (curl 28, 4.0 s) 192.168.1.179:8084 -> 000
192.168.1.125:8081 -> 000 (curl 28, 4.0 s) 192.168.1.125:8084 -> 000
# public: internal hostnames have no route on the public listener
curl -H 'Host: grafana.lab.internal' http://10.10.0.2:8080/ -> 404
curl -H 'Host: hubble.lab.internal' http://10.10.0.2:8080/ -> 404
# tunnel ingress = 9 entries, every service http://10.10.0.2:8080, no lab.internal
# public sites through the tunnel still 200 (from rpi):
# siriusdevops.com 200 forgejo.siriusdevops.com 200 piedmonthomesvc.com 200
# siriusgrowthsolutions.com 200
```
Commit `48b2b6a` (label removal is host state — `kubectl label node rpi
node-role.kubernetes.io/gateway-`; the manifests, the counter-augmented nft file
and this document are in git).