hubble: move the UI listener to 8084 — 8082 is taken on rpi
Cilium binds every Gateway listener on 0.0.0.0 on EVERY gateway node, and the Pi
still runs leftover Docker site containers: handyman-site holds 127.0.0.1:8082
and its nginx holds 127.0.0.1:8083 (a 127.0.0.1 bind still blocks a 0.0.0.0
one). Binding 8082 there made xDS reject the listener on rpi
("cannot bind '0.0.0.0:8082': Address already in use" at ~2/s) and restarted
cilium-envoy on the node that fronts the public ingress — the UI worked or not
depending on which node answered.
8084 measured free on both gateway nodes (rpi, siriussec) before the change.
Firewall moved with it: siriussec nft dport set { 8081, 8084 }, rpi ufw trio for
8084 inserted above the LAN catch-all and the 8082 rules deleted.
URL: http://10.10.0.2:8084/ (bare IP, no /etc/hosts) — same as Grafana on 8081.
This commit is contained in:
parent
b4d2738750
commit
a287dc8dfa
7 changed files with 62 additions and 27 deletions
|
|
@ -38,9 +38,14 @@ only". Consequences:
|
||||||
**404**. A hostname-less route matches any `Host` on its listener, so the
|
**404**. A hostname-less route matches any `Host` on its listener, so the
|
||||||
named `http://<name>.lab.internal:8081` URL keeps working for laptops that
|
named `http://<name>.lab.internal:8081` URL keeps working for laptops that
|
||||||
do have the hosts line.
|
do have the hosts line.
|
||||||
- **One service per listener port.** Two hostname-less routes on one listener
|
- **One service per listener port AND per Gateway.** Two hostname-less routes
|
||||||
make precedence ambiguous, so the next internal service takes a new port
|
on one listener make precedence ambiguous — and worse, Cilium renders **one
|
||||||
(and its own firewall rules, §5) instead of sharing 8081.
|
RouteConfiguration per Gateway**, shared by all of that Gateway's listeners,
|
||||||
|
so two hostname-less routes merge into a single route with `weightedClusters`
|
||||||
|
weight 1/1: every request then hits a random backend, on *every* port of the
|
||||||
|
gateway. Splitting them onto different ports of the same Gateway does not
|
||||||
|
help. Each bare-IP service therefore gets its own **Gateway** (its own port,
|
||||||
|
its own RouteConfiguration) — see `gateway-hubble-ui.yaml` and §9.
|
||||||
|
|
||||||
Public traffic has no path here: the only public ingress is the cloudflared
|
Public traffic has no path here: the only public ingress is the cloudflared
|
||||||
tunnel, whose ingress list is an explicit allow-list of hostnames pointing at
|
tunnel, whose ingress list is an explicit allow-list of hostnames pointing at
|
||||||
|
|
@ -51,21 +56,23 @@ tunnel, whose ingress list is an explicit allow-list of hostnames pointing at
|
||||||
|
|
||||||
| Object / unit | Where | Purpose |
|
| Object / unit | Where | Purpose |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `Gateway internal/internal` | `infrastructure/networking/internal/gateway.yaml` (Flux: `infrastructure`) | listener `http-internal`, **port 8081**, `allowedRoutes: All` so any namespace can attach |
|
| `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 |
|
||||||
| `HTTPRoute <svc>` | the app's own tree (e.g. `monitoring/controllers/home/httproute.yaml`) | `parentRefs: internal/internal#http-internal`, `hostnames: [<name>.lab.internal]` |
|
| `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 |
|
||||||
| `table inet internal_gw` + `internal-gw-firewall.service` | siriussec host (`/etc/nftables.d/internal-gw.nft`) | drop `:8081` from everything but `10.10.0.0/24`, `10.244.0.0/16`, `lo` |
|
| `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`** |
|
||||||
| ufw rules (inserted above the LAN catch-all) | rpi host | same policy for `:8081` |
|
| `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 |
|
| `infrastructure/networking/internal/host-firewall/` | repo | the two host artifacts + install/verify instructions |
|
||||||
|
|
||||||
Both firewalls must be in place: Envoy listens on **both** gateway nodes, so
|
Both firewalls must be in place: Envoy listens on **both** gateway nodes, so
|
||||||
leaving either node's 8081 open leaks the service to the LAN from that node's
|
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).
|
address (and the other node answers 503, which still proves a listener exists).
|
||||||
|
|
||||||
## 3. Current internal services
|
## 3. Current internal services
|
||||||
|
|
||||||
| Service | URL (over WireGuard) | Optional client `/etc/hosts` line | Route |
|
| Service | URL (over WireGuard) | Optional client `/etc/hosts` line | Route | Port |
|
||||||
|---|---|---|---|
|
|---|---|---|---|---|
|
||||||
| Grafana | **`http://10.10.0.2:8081/`** (also `http://grafana.lab.internal:8081/`) | `10.10.0.2 grafana.lab.internal` | `monitoring/grafana` |
|
| Grafana | **`http://10.10.0.2:8081/`** (also `http://grafana.lab.internal:8081/`) | `10.10.0.2 grafana.lab.internal` | `monitoring/grafana` | 8081 |
|
||||||
|
| Hubble UI | **`http://10.10.0.2:8084/`** (also `http://hubble.lab.internal:8084/`) | `10.10.0.2 hubble.lab.internal` | `kube-system/hubble-ui` | 8084 |
|
||||||
|
|
||||||
**The rule: every internal service must be reachable as
|
**The rule: every internal service must be reachable as
|
||||||
`http://10.10.0.2:<port>/` with no `Host` header and no hosts-file entry**,
|
`http://10.10.0.2:<port>/` with no `Host` header and no hosts-file entry**,
|
||||||
|
|
@ -87,7 +94,25 @@ works.
|
||||||
2. **Deploy the workload** in its own namespace, pinned with
|
2. **Deploy the workload** in its own namespace, pinned with
|
||||||
`nodeSelector: {kubernetes.io/hostname: siriussec}` (amd64 + local-path; the
|
`nodeSelector: {kubernetes.io/hostname: siriussec}` (amd64 + local-path; the
|
||||||
Pi is arm64 and its listener only serves pods scheduled on the Pi).
|
Pi is arm64 and its listener only serves pods scheduled on the Pi).
|
||||||
3. **Add the route** next to the workload — **without `hostnames`**:
|
3. **Add the Gateway** (its own object, its own port, its own
|
||||||
|
RouteConfiguration) — copy `infrastructure/networking/internal/gateway-hubble-ui.yaml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: Gateway
|
||||||
|
metadata:
|
||||||
|
name: <svc>
|
||||||
|
namespace: internal
|
||||||
|
spec:
|
||||||
|
gatewayClassName: cilium
|
||||||
|
listeners:
|
||||||
|
- name: http-internal
|
||||||
|
protocol: HTTP
|
||||||
|
port: <port> # unique; firewalled first, see §5
|
||||||
|
allowedRoutes: {namespaces: {from: All}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then the route next to the workload — **without `hostnames`**:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: gateway.networking.k8s.io/v1
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
|
@ -97,9 +122,9 @@ works.
|
||||||
namespace: <ns>
|
namespace: <ns>
|
||||||
spec:
|
spec:
|
||||||
parentRefs:
|
parentRefs:
|
||||||
- name: internal
|
- name: <svc> # the Gateway above, NOT `internal`
|
||||||
namespace: internal
|
namespace: internal
|
||||||
sectionName: http-internal-<port> # its own listener on its own port
|
sectionName: http-internal
|
||||||
rules:
|
rules:
|
||||||
- matches:
|
- matches:
|
||||||
- path: {type: PathPrefix, value: /}
|
- path: {type: PathPrefix, value: /}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ metadata:
|
||||||
app.kubernetes.io/part-of: cilium
|
app.kubernetes.io/part-of: cilium
|
||||||
spec:
|
spec:
|
||||||
parentRefs:
|
parentRefs:
|
||||||
# Dedicated Gateway on port 8082 — deliberately NOT the shared `internal`
|
# Dedicated Gateway on port 8084 — deliberately NOT the shared `internal`
|
||||||
# gateway. There is no `hostnames` field here on purpose: the route must
|
# gateway. There is no `hostnames` field here on purpose: the route must
|
||||||
# match a request whose Host header is the bare IP (10.10.0.2:8082), which
|
# match a request whose Host header is the bare IP (10.10.0.2:8084), which
|
||||||
# is the only form a phone can use. Cilium merges hostname-less routes that
|
# is the only form a phone can use. Cilium merges hostname-less routes that
|
||||||
# share a Gateway into one 50/50 weighted route, so a bare-IP service needs
|
# share a Gateway into one 50/50 weighted route, so a bare-IP service needs
|
||||||
# its own Gateway as well as its own port.
|
# its own Gateway as well as its own port.
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,17 @@ spec:
|
||||||
listeners:
|
listeners:
|
||||||
- name: http-internal
|
- name: http-internal
|
||||||
protocol: HTTP
|
protocol: HTTP
|
||||||
port: 8082
|
# PORT MUST BE FREE ON *EVERY* NODE THAT RUNS cilium-envoy (rpi 10.10.0.1 and
|
||||||
|
# siriussec 10.10.0.2 — `kubectl -n kube-system get pods -l
|
||||||
|
# k8s-app=cilium-envoy -o wide`). Cilium binds 0.0.0.0:<port> hostNetwork on
|
||||||
|
# all of them, so a port already held by anything else on ANY gateway node
|
||||||
|
# makes xDS reject the listener there ("cannot bind '0.0.0.0:8084': Address
|
||||||
|
# already in use") and crashloops that node's Envoy — which fronts the
|
||||||
|
# public ingress. The Pi still runs leftover Docker site containers:
|
||||||
|
# handyman-site holds 127.0.0.1:8082 and its nginx holds 127.0.0.1:8083, so
|
||||||
|
# both are unusable here (a 127.0.0.1 bind still conflicts with 0.0.0.0).
|
||||||
|
# Check per node before choosing: `ss -lntH "sport = :<port>" | wc -l` = 0.
|
||||||
|
port: 8084
|
||||||
allowedRoutes:
|
allowedRoutes:
|
||||||
namespaces:
|
namespaces:
|
||||||
from: All
|
from: All
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ spec:
|
||||||
# listeners, so two routes that both match `Prefix: /` with no hostnames are
|
# listeners, so two routes that both match `Prefix: /` with no hostnames are
|
||||||
# merged into a single route with `weightedClusters` weight 1/1 — every
|
# merged into a single route with `weightedClusters` weight 1/1 — every
|
||||||
# request then lands on a random backend, on every port of the gateway.
|
# request then lands on a random backend, on every port of the gateway.
|
||||||
# Proven live: http://10.10.0.2:8081/ and :8082/ each served Grafana ~58% and
|
# Proven live: http://10.10.0.2:8081/ and :8084/ each served Grafana ~58% and
|
||||||
# Hubble UI ~42% of the time once Hubble's bare route existed here.
|
# Hubble UI ~42% of the time once Hubble's bare route existed here.
|
||||||
#
|
#
|
||||||
# A service that must answer on its bare IP therefore gets its OWN Gateway
|
# A service that must answer on its bare IP therefore gets its OWN Gateway
|
||||||
# object, which gets its own Envoy RouteConfiguration — see
|
# object, which gets its own Envoy RouteConfiguration — see
|
||||||
# `gateway-hubble-ui.yaml` (port 8082). One bare-IP service per Gateway.
|
# `gateway-hubble-ui.yaml` (port 8084). One bare-IP service per Gateway.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ are *both* listening on the LAN interfaces; the Gateway API object cannot say
|
||||||
| siriussec (10.10.0.2) | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` |
|
| siriussec (10.10.0.2) | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` |
|
||||||
| rpi (10.10.0.1) | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` |
|
| rpi (10.10.0.1) | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` |
|
||||||
|
|
||||||
Effective policy for `:8081` (Grafana) and `:8082` (Hubble UI) on both hosts:
|
Effective policy for `:8081` (Grafana) and `:8084` (Hubble UI) on both hosts:
|
||||||
**accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything
|
**accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything
|
||||||
else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a
|
else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a
|
||||||
new internal listener port is a LAN exposure until it is added here.
|
new internal listener port is a LAN exposure until it is added here.
|
||||||
|
|
@ -36,7 +36,7 @@ Verify:
|
||||||
# siriussec
|
# siriussec
|
||||||
nft list table inet internal_gw
|
nft list table inet internal_gw
|
||||||
# rpi
|
# rpi
|
||||||
ufw status | grep -E '8081|8082'
|
ufw status | grep -E '8081|8084'
|
||||||
```
|
```
|
||||||
|
|
||||||
Negative test from the LAN must be a timeout (DROP), never 200:
|
Negative test from the LAN must be a timeout (DROP), never 200:
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
# Final order per port: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest.
|
# Final order per port: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest.
|
||||||
#
|
#
|
||||||
# Ports: 8081 = Grafana (`internal` Gateway listener http-internal),
|
# Ports: 8081 = Grafana (`internal` Gateway listener http-internal),
|
||||||
# 8082 = Hubble UI (`internal` Gateway listener hubble-ui).
|
# 8084 = Hubble UI (`internal` Gateway listener hubble-ui).
|
||||||
# Add a new internal listener port to PORTS; the loop is idempotent, so
|
# Add a new internal listener port to PORTS; the loop is idempotent, so
|
||||||
# re-running after a port is already firewalled only adds what is missing.
|
# re-running after a port is already firewalled only adds what is missing.
|
||||||
#
|
#
|
||||||
# Run as root on rpi (192.168.1.125).
|
# Run as root on rpi (192.168.1.125).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
PORTS="${PORTS:-8081 8082}"
|
PORTS="${PORTS:-8081 8084}"
|
||||||
|
|
||||||
for port in $PORTS; do
|
for port in $PORTS; do
|
||||||
if ufw status | grep -q "${port}/tcp"; then
|
if ufw status | grep -q "${port}/tcp"; then
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/sbin/nft -f
|
#!/usr/sbin/nft -f
|
||||||
# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana) and 8082
|
# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana) and 8084
|
||||||
# (Hubble UI).
|
# (Hubble UI).
|
||||||
#
|
#
|
||||||
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the
|
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the
|
||||||
|
|
@ -22,13 +22,13 @@ table inet internal_gw {
|
||||||
type filter hook input priority filter; policy accept;
|
type filter hook input priority filter; policy accept;
|
||||||
|
|
||||||
# local process / kubelet probes
|
# local process / kubelet probes
|
||||||
tcp dport { 8081, 8082 } iifname "lo" accept
|
tcp dport { 8081, 8084 } iifname "lo" accept
|
||||||
|
|
||||||
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes)
|
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes)
|
||||||
# and the pod network (in-cluster scrapers, probes)
|
# and the pod network (in-cluster scrapers, probes)
|
||||||
tcp dport { 8081, 8082 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } accept
|
tcp dport { 8081, 8084 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } accept
|
||||||
|
|
||||||
# everything else: LAN, tailscale, public
|
# everything else: LAN, tailscale, public
|
||||||
tcp dport { 8081, 8082 } counter drop
|
tcp dport { 8081, 8084 } counter drop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue