infrastructure(garage): commit the config, prove WG-only, split keys, back it up, scrape it

Garage was the only piece of the platform in no git repository and reachable
from more than WireGuard. This is a hardening/ownership pass, not a migration —
the container stays on the Pi.

- infrastructure/garage/: docker-compose.yml (pinned dxflrs/garage:v1.1.0,
  every publish on an explicit 10.10.0.1 / 127.0.0.1 address, no 0.0.0.0),
  garage.toml (rpc_secret moved to /etc/garage/garage.env, [s3_web]/3902
  removed, admin API on 3903 for metrics), README (apply, state, restore,
  keys, backup, metrics) and an explicit note that Flux does not apply it.
- host/garage-firewall.nft: PREROUTING priority -140 drop of 3900-3903 from
  anything but lo/wg0/wg-remote. Docker's DNAT bypasses ufw's INPUT chain, so
  ufw alone cannot stop a compose typo from publishing S3 on the LAN.
  Measured: a 0.0.0.0:3902 publish stayed unreachable from the LAN and the
  drop counter incremented.
- backup/: garage-backup.sh meta|data + systemd timers (meta hourly, data
  nightly) rsyncing to [email protected]:/root/garage-backup over wg-remote.
  Nothing else backs up Forgejo or the PG PVCs; that stays uncovered.
- monitoring/controllers/home/garage.yaml: Service + EndpointSlice +
  ServiceMonitor for 10.10.0.1:3903 and five alerts. Target is UP.
- apps/base/siriusdevops/networkpolicy-site-egress.yaml: first policy in the
  namespace. CiliumNetworkPolicy, not a k8s NetworkPolicy: 10.10.0.1 is a
  cluster node (reserved:remote-node), so ipBlock 10.10.0.1/32 is inert.
  Egress whitelist = TCP 3900 to a node + cluster DNS; measured 403 on 3900,
  timeouts on 3900-adjacent 5000/3903, on 10.10.0.2:8080 and on the internet.

Keys: ci-push (W only, siriusdevops-media) and site-fetch (R only, same
bucket) replace the shared ci-key, which is deleted. The k8s Secret and the
two Forgejo repo secrets were repointed. No key material is in this commit.
This commit is contained in:
Lance Walters 2026-11-19 16:32:58 -05:00
commit d82e1b9f2a
15 changed files with 802 additions and 0 deletions

View file

@ -0,0 +1,41 @@
#!/usr/sbin/nft -f
# Garage inbound guard — defence in depth for the S3/metrics listeners.
#
# WHY THIS EXISTS AND WHY IT IS NOT JUST ufw:
# Docker publishes container ports through a DNAT rule in the `nat`
# PREROUTING chain. That traversal never reaches ufw's INPUT chain, so a
# compose typo that publishes `0.0.0.0:3900:3900` would be reachable from the
# LAN and (worse) from anywhere the router forwards, with ufw still reporting
# "default deny (incoming)". This table sits in PREROUTING at priority -140 —
# after mangle (-150), before DNAT (-100) — so it drops the packet BEFORE
# Docker can rewrite it, whatever address compose asked for.
#
# Effective policy for 3900-3903: accept from WireGuard (wg0, the remote hub
# link wg-remote) and loopback, drop everything else (LAN eth0/wlan0, tailscale,
# public). DROP rather than REJECT so an off-mesh scan sees a filtered port and
# learns nothing.
#
# Scope is deliberately narrow: only Garage's ports. Do not widen this table
# into a general host firewall — the Pi's ufw already owns that, and moving
# k8s/wgportal/DNS traffic here would strand the cluster.
#
# Loaded by garage-firewall.service. `destroy` (not `delete`) so re-running the
# unit replaces the table instead of appending a duplicate copy, and does not
# fail on first install.
#
# Changing Garage's ports means changing this set AND docker-compose.yml AND
# the rpi ufw rules in one go; a port in one place only is how you get a
# listener that answers on the LAN.
destroy table inet garage_guard
table inet garage_guard {
chain prerouting {
type filter hook prerouting priority -140; policy accept;
# WireGuard only: the mesh hub link and loopback.
iifname { "lo", "wg0", "wg-remote" } tcp dport { 3900, 3901, 3902, 3903 } counter accept
# Anything else — LAN, tailscale, public, or a future interface that
# nobody remembered to add above.
tcp dport { 3900, 3901, 3902, 3903 } counter drop
}
}

View file

@ -0,0 +1,25 @@
# /etc/systemd/system/garage-firewall.service (rpi)
#
# Host unit, installed by hand (not Flux-managed) — the file lives in git at
# infrastructure/garage/host/. Same shape as k8s-api-firewall.service and
# internal-gw-firewall.service on siriussec.
#
# Ordering note: no Requires= on wg-quick@wg0. The Pi's wg0 is normally brought
# up by hand / by wgportal and the template unit can be inactive; a hard
# dependency would make this unit fail outright and silently leave Garage
# unguarded. Ordering against docker is deliberately absent: this table sits at
# PREROUTING priority -140 so it is evaluated before Docker's DNAT (-100)
# regardless of which of the two loaded first — and `After=docker.service`
# together with a `Before=` on the same unit would be an ordering cycle.
[Unit]
Description=Drop off-WireGuard inbound to Garage (3900-3903) before Docker DNAT
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/nft -f /etc/nftables.d/garage_guard.nft
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Install the Garage inbound guard on rpi. Idempotent; safe to re-run.
#
# sudo ./install-garage-firewall.sh
#
# Verifies the table afterwards instead of trusting `systemctl start`'s exit 0.
set -euo pipefail
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
install -D -m 0644 "$here/garage-firewall.nft" /etc/nftables.d/garage_guard.nft
install -D -m 0644 "$here/garage-firewall.service" /etc/systemd/system/garage-firewall.service
systemctl daemon-reload
systemctl enable --now garage-firewall.service
# Prove it loaded rather than assuming: the table must exist and carry both the
# accept and the drop rule.
nft list table inet garage_guard >/dev/null
nft list table inet garage_guard | grep -q 'dport { 3900, 3901, 3902, 3903 }'
echo "OK: garage_guard loaded"
nft list table inet garage_guard