Add firewall and home LAN access docs, ComfyUI image generation, and backup plan

Document the Hetzner Cloud Firewall posture (inbound from private/home only, outbound allow-all, egress-only IPv6, public IPs on workers) in a new `Cluster_admin/firewall.md` and reference it from `AGENTS.md`, `Environment.md`, and `README.md`. Update the Mailu README to note that SMTP/IMAP ports are not currently exposed.

Add `HomeAccess/` with a privileged DaemonSet and README that give cluster nodes a route to `192.168.8.0/24` via point-to-point GRE tunnels to the master and its WireGuard tunnel.

Wire Open WebUI to ComfyUI on pop-os through a new `openwebui-imagegen` ConfigMap consumed via `envFrom`, with migration notes covering the PersistentConfig DB override.

Bump kube-prometheus-stack to 88.6.1 with an 8GB `retentionSize` cap, grow the postgres PVC to 50Gi, and add a PostgreSQL backup plan for pg_dumpall/rclone streaming to a Hetzner Storage Box.
This commit is contained in:
2026-12-01 12:36:14 +02:00
parent 975c059ecf
commit 36fbaf171a
13 changed files with 618 additions and 8 deletions
+129
View File
@@ -0,0 +1,129 @@
# Home access from the cluster
Lets pods and nodes reach the home LAN at `192.168.8.0/24` (the `pop-os`
workstation lives there) through the master's existing WireGuard tunnel.
```
pod on worker --Cilium--> worker node
| SNAT to 169.254.8.X, GRE (outer 10.1.0.X -> 10.1.0.3)
v
master 10.1.0.3
| forward + MASQUERADE out wg0 (src 192.168.5.3)
v
home router --> 192.168.8.28
```
Two things make this less obvious than it looks:
1. **Hetzner's private network is routed, not L2.** Each node has a `/32`
(`10.1.0.x/32`) with a gateway at `10.1.0.1`; you cannot ARP a peer and use
it as a next hop.
2. **It drops non-private sources.** A packet forwarded by the master with
`source 192.168.8.x` never reaches the worker's NIC, so the return path has
to be tunnelled as well.
Hence the point-to-point GRE tunnels (`169.254.8.0/24`) between each worker and
the master. The inner packet keeps its real source end to end; only the outer
header uses the private node IPs. The master then masquerades `169.254.8.0/24`
to `192.168.5.3` on `wg0`, the address the PC already answers.
| Worker private IP | Tunnel pair |
|---|---|
| `10.1.0.2` | `169.254.8.0/31` (worker `.0`, master `.1`) |
| `10.1.0.4` | `169.254.8.4/31` (worker `.4`, master `.5`) |
The worker list is hardcoded in the DaemonSet (`WORKERS`). Update it when a node
is added, removed or renumbered.
## Prerequisites (host-side, not managed here)
1. On `master-4gb-hel1-2`, the `/etc/wireguard/wg0.conf` peer for the home
router must list the home LAN:
```ini
AllowedIPs = 192.168.5.0/24, 192.168.8.0/24
```
Reload with `wg syncconf wg0 <(wg-quick strip wg0)` **and** add the route if
`ip route get 192.168.8.28` does not say `dev wg0` (`wg syncconf` does not
install routes):
```bash
ip route replace 192.168.8.0/24 dev wg0
ip route get 192.168.8.28 # expect: dev wg0 src 192.168.5.3
```
2. The home router routes `192.168.8.0/24` into the WireGuard tunnel and
allows WireGuard ↔ LAN forwarding.
3. Hetzner Cloud Firewall `allow-all-home` includes `192.168.8.0/24`.
## Deploy
```bash
kubectl apply -f HomeAccess/home_lan_router_daemonset.yaml
kubectl -n kube-system rollout status ds/home-lan-router
```
The DaemonSet is privileged with `hostNetwork: true` because it programs the
node's interfaces, routes and iptables. A 60 s reconcile loop re-applies
everything, so reboots, drains, Cilium upgrades and iptables flushes heal
themselves.
## Verify
```bash
# master: tunnels, NAT
kubectl -n kube-system exec ds/home-lan-router -- ip -br addr show | grep home-gw
kubectl -n kube-system exec ds/home-lan-router -- iptables -t nat -S POSTROUTING | grep 192.168.8
# worker: tunnel + route
kubectl -n kube-system exec <worker-pod> -- ip route show 192.168.8.0/24
# end-to-end (ICMP is the quickest; use any listening TCP port on the PC)
kubectl -n kube-system exec <worker-pod> -- ping -c2 192.168.8.28
kubectl -n kube-system exec <worker-pod> -- nc -vz -w2 192.168.8.28 22
kubectl -n gitea exec deploy/gitea -- curl -s -o /dev/null -w '%{http_code}\n' -m 5 http://192.168.8.28:<port-on-the-pc>/
```
`<port-on-the-pc>` needs an HTTP listener; when nothing is running on `pop-os`,
the ICMP and `nc` checks are enough.
## Notes
- Only `192.168.8.0/24` becomes reachable from pods, not the rest of the home
network.
- `pop-os` gets its address over DHCP. The route is subnet-wide, so a lease
change does not break routing; add a DHCP reservation on the UniFi gateway if
anything references the address.
- The worker `rp_filter` must be permissive (`0`) on the GRE interfaces and the
master's `all.rp_filter` must be `0`; the DaemonSet sets both. This is what
lets the forwarded, un-NAT'd reply enter the stack.
- TCP MSS is clamped to `1356` (`1396` GRE inner MTU − 40) on the workers, so
payloads do not black-hole on PMTUD.
- The host and the containers both use the `nf_tables` iptables backend, so
rules are visible and editable from either side.
## Rollback
```bash
kubectl delete -f HomeAccess/home_lan_router_daemonset.yaml
```
Host state (interfaces, routes, iptables rules) survives pod deletion; remove it
manually or reboot the nodes:
```bash
# workers
ip tunnel del home-gw
iptables -t nat -D CILIUM_POST_nat -d 192.168.8.0/24 -j RETURN
iptables -t nat -D POSTROUTING -s 10.0.0.0/8 -d 192.168.8.0/24 -j SNAT --to-source 169.254.8.X
iptables -D FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# master
ip tunnel del home-gw-0 home-gw-4
iptables -t nat -D POSTROUTING -s 169.254.8.0/24 -d 192.168.8.0/24 -o wg0 -j MASQUERADE
iptables -t nat -D POSTROUTING -s 10.0.0.0/8 -d 192.168.8.0/24 -o wg0 -j MASQUERADE
iptables -D FORWARD -i 'home-gw+' -o wg0 -j ACCEPT
iptables -D FORWARD -i wg0 -o 'home-gw+' -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
```
+149
View File
@@ -0,0 +1,149 @@
# Gives the cluster a route to the home LAN (192.168.8.0/24) through the
# master's WireGuard tunnel (wg0) and SNATs it to the master's WG address, so
# replies come back over the path the home router already knows.
#
# Hetzner's private network is routed (/32 per node) and drops packets whose
# source is not a private address, so worker traffic cannot simply be routed
# "via 10.1.0.3". Instead each worker gets a point-to-point GRE tunnel to the
# master: the inner packet keeps its real source, the outer packet uses the
# private node IPs.
#
# Prerequisite (host-side, see README.md): the master's wg0 peer must list
# 192.168.8.0/24 in AllowedIPs.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: home-lan-router
namespace: kube-system
labels:
app: home-lan-router
spec:
selector:
matchLabels:
app: home-lan-router
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10%
template:
metadata:
labels:
app: home-lan-router
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
priorityClassName: system-node-critical
tolerations:
- operator: Exists
containers:
- name: router
image: nicolaka/netshoot:v0.13
command: ["/bin/bash", "-c"]
args:
- |
set -u
HOME_LAN="192.168.8.0/24"
MASTER_IP="10.1.0.3"
WG_IF="wg0"
TUN_NET="169.254.8.0/24"
TUN_MTU=1396
MSS=1356
# Worker private IPs. Update this list when a node is added,
# removed or renumbered. The master ignores its own address.
WORKERS="10.1.0.2 10.1.0.4"
is_master() {
# The label is empty on workers; wg0 is a fallback in case the
# label lookup comes back empty on the master.
[ -n "${CONTROL_PLANE:-}" ] || ip link show "$WG_IF" >/dev/null 2>&1
}
# /31 pair for a worker, derived from the last octet of its IP:
# 10.1.0.2 -> 169.254.8.0/31, 10.1.0.4 -> 169.254.8.4/31.
tun_net() { echo $(( ($1 - 2) * 2 )); }
master_loop() {
for w in $WORKERS; do
local last dev net
last="${w##*.}"
net="$(tun_net "$last")"
dev="home-gw-$net"
if ! ip link show "$dev" >/dev/null 2>&1; then
ip tunnel add "$dev" mode gre local "$MASTER_IP" remote "$w" ttl 255
fi
ip link set "$dev" mtu "$TUN_MTU" up
ip addr replace "169.254.8.$((net + 1))/31" dev "$dev"
ip route replace "169.254.8.$net/31" dev "$dev"
sysctl -qw "net.ipv4.conf.$dev.rp_filter=0" || true
done
sysctl -qw net.ipv4.conf.all.rp_filter=0 || true
sysctl -qw net.ipv4.ip_forward=1 || true
for src in "$TUN_NET" "10.0.0.0/8"; do
iptables -t nat -C POSTROUTING -s "$src" -d "$HOME_LAN" -o "$WG_IF" -j MASQUERADE 2>/dev/null \
|| iptables -t nat -A POSTROUTING -s "$src" -d "$HOME_LAN" -o "$WG_IF" -j MASQUERADE
done
iptables -C FORWARD -i 'home-gw+' -o "$WG_IF" -j ACCEPT 2>/dev/null \
|| iptables -I FORWARD 1 -i 'home-gw+' -o "$WG_IF" -j ACCEPT
iptables -C FORWARD -i "$WG_IF" -o 'home-gw+' -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 2>/dev/null \
|| iptables -I FORWARD 1 -i "$WG_IF" -o 'home-gw+' -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
}
worker_loop() {
local local_ip last net dev
local_ip="$(ip route get "$MASTER_IP" | sed -n 's/.* src \([^ ]*\).*/\1/p')"
[ -n "$local_ip" ] || { echo "ERROR: cannot determine local IP"; return 1; }
last="${local_ip##*.}"
net="$(tun_net "$last")"
dev="home-gw"
if ! ip link show "$dev" >/dev/null 2>&1; then
ip tunnel add "$dev" mode gre local "$local_ip" remote "$MASTER_IP" ttl 255
fi
ip link set "$dev" mtu "$TUN_MTU" up
ip addr replace "169.254.8.$net/31" dev "$dev"
ip route replace "$HOME_LAN" via "169.254.8.$((net + 1))" dev "$dev"
sysctl -qw "net.ipv4.conf.$dev.rp_filter=0" || true
sysctl -qw net.ipv4.conf.all.rp_filter=0 || true
# Let our SNAT rule own this destination, otherwise Cilium
# masquerades to a tunnel device that has no address.
iptables -t nat -C CILIUM_POST_nat -d "$HOME_LAN" -j RETURN 2>/dev/null \
|| iptables -t nat -I CILIUM_POST_nat 1 -d "$HOME_LAN" -j RETURN
iptables -t nat -C POSTROUTING -s "10.0.0.0/8" -d "$HOME_LAN" -j SNAT --to-source "169.254.8.$net" 2>/dev/null \
|| iptables -t nat -A POSTROUTING -s "10.0.0.0/8" -d "$HOME_LAN" -j SNAT --to-source "169.254.8.$net"
iptables -C FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 2>/dev/null \
|| iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -t mangle -C FORWARD -o "$dev" -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss "$MSS" 2>/dev/null \
|| iptables -t mangle -A FORWARD -o "$dev" -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss "$MSS"
iptables -t mangle -C FORWARD -i "$dev" -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss "$MSS" 2>/dev/null \
|| iptables -t mangle -A FORWARD -i "$dev" -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss "$MSS"
}
echo "home-lan-router: node=${NODE_NAME:-unknown} role=$(is_master && echo master || echo worker)"
while true; do
if is_master; then
master_loop
else
worker_loop
fi
sleep 60
done
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: CONTROL_PLANE
valueFrom:
fieldRef:
fieldPath: "metadata.labels['node-role.kubernetes.io/control-plane']"
securityContext:
privileged: true
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
memory: 64Mi