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

@ -7,3 +7,4 @@ resources:
- service-site.yaml
- service-api.yaml
- httproute.yaml
- networkpolicy-site-egress.yaml

View file

@ -0,0 +1,70 @@
# Egress policy for the public site pod — the first policy in this namespace
# (there were zero before 2026-11-19, so every pod could reach every WireGuard
# address).
#
# What it is for: `siriusdevops-site` runs an initContainer that pulls owner
# media out of the private Garage bucket over the mesh
# (http://10.10.0.1:3900). Nothing else about that pod needs to talk to the
# WireGuard network, and the pod is internet-facing, so it is the right first
# pod to fence off.
#
# WHY A CiliumNetworkPolicy AND NOT A networking.k8s.io NetworkPolicy:
# 10.10.0.1 is a CLUSTER NODE (rpi, the WireGuard hub), not a bare address.
# Cilium resolves it to `reserved:remote-node` (identity 6) in its ipcache
# (`cilium-dbg bpf ipcache list | grep 10.10.0.1` -> identity=6), and `ipBlock`
# / toCIDR rules are only evaluated for `reserved:world`. A standard
# NetworkPolicy with `ipBlock: 10.10.0.1/32` is silently inert here — measured:
# the pod's request to 10.10.0.1:3900 timed out exactly like the denied ports,
# while Prometheus (unrestricted namespace) scraped the same host fine.
#
# The narrower `toNodes: [{matchLabels: {kubernetes.io/hostname: rpi}}]` form
# would name the node exactly, but the agent rejects it unless Cilium runs with
# `enable-node-selector-labels: true` — status: "FromNodes/ToNodes rules can
# only be applied when the \"enable-node-selector-labels\" flag is set". Rather
# than change a cluster-wide Cilium flag for one policy, this uses the
# `remote-node` entity: any cluster node, TCP 3900 only. Every cluster node is
# on the WireGuard overlay, so this still cannot reach the LAN or the public
# internet, and the port scope is what makes the denial test meaningful.
#
# Scope: Egress only, one pod selector. Other pods in siriusdevops (and every
# other namespace) remain unrestricted — this proves the pattern, it is not
# namespace segregation. Ingress is untouched: the Cilium Gateway must still be
# able to reach nginx on :80.
#
# The policy is a whitelist: once it selects a pod, ALL egress from that pod is
# denied except what is listed. Two allowances:
# 1. TCP 3900 to a cluster node — Garage's S3 API on 10.10.0.1. Deliberately
# port-scoped: 10.10.0.1 also serves the container registry on 5000, and
# that stays unreachable from this pod.
# 2. Cluster DNS. Nothing in this pod resolves names today (the S3 endpoint
# is a literal IP); the rule costs one line and removes the trap of
# breaking name resolution in a pod that later grows a container.
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: siriusdevops-site-egress
namespace: siriusdevops
spec:
endpointSelector:
matchLabels:
app: siriusdevops-site
egress:
# Garage S3 API, on a WireGuard-overlay node, port 3900 only.
- toEntities:
- remote-node
toPorts:
- ports:
- port: "3900"
protocol: TCP
# Cluster DNS (CoreDNS) only.
- toEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: kube-system
k8s-app: kube-dns
toPorts:
- ports:
- port: "53"
protocol: UDP
- port: "53"
protocol: TCP