homek8s/infrastructure/garage/README.md
Lance Walters d82e1b9f2a 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.
2026-11-19 16:32:58 -05:00

12 KiB

Garage — the private object store (rpi, outside the cluster)

Garage is a single-node S3-compatible object store running as a Docker container on rpi (the WireGuard hub, 10.10.0.1). It is deliberately not a Kubernetes workload: a storage service should not be a pod on a three-node homelab where rebooting the control plane is routine.

Its only network path is the WireGuard mesh. There is no public hostname, no Cloudflare tunnel, no DNS record, no website listener, and no public bucket.

This directory is NOT applied by Flux

Flux watches ./clusters/homek8s of sirius/homek8s. Nothing in that path references this directory, and that is intentional — Flux manages the cluster, not the Pi's host containers. A push here changes nothing on the Pi.

It is committed for one reason: reproducibility. A rebuilt Pi comes back from this directory plus one backup of meta/ and data/. Before 2026-11-19 the Garage config existed only at /home/sirius/websites/garage/garage.toml on the host, in no git repository anywhere — the only piece of the platform that neither Flux nor a repo could rebuild.

What runs

Container garage, image dxflrs/garage:v1.1.0 (pinned tag, never :latest)
Compose file /etc/garage/docker-compose.yml (installed from here)
Config /etc/garage/garage.toml (installed from garage.toml here)
RPC secret /etc/garage/garage.env → GARAGE_RPC_SECRET, 0600 root:root, not in git
State /home/sirius/websites/garage/meta/ (metadata) and .../data/ (objects)
Node d053db4dfc97bf78, zone dc1, capacity 100 GB, replication_factor = 1

State paths were kept at the historical locations on purpose, so switching to this compose file moved no data.

Ports — every publish is an explicit address

Host address Port Purpose
10.10.0.1 3900 S3 API — the only endpoint the cluster consumes
10.10.0.1 3903 /metrics for Prometheus
127.0.0.1 3900 host-local S3, for backup verification on the Pi

There is no 0.0.0.0 publish and no 3901/3902 publish at all (see "Removed" below). Docker scopes a specific-IP publish to that destination, so 192.168.1.125:3900 and any public address are closed.

Defence in depth (this is the load-bearing part)

host/garage-firewall.nft is an nftables table in PREROUTING priority -140, i.e. before Docker's DNAT (-100). ufw cannot do this job: Docker's port publishing bypasses ufw's INPUT chain entirely, so a compose typo that published 0.0.0.0:3900 would be reachable with ufw still reporting "default deny (incoming)". The nft table drops 3900-3903 from everything that is not wg0/wg-remote/lo, whatever address Docker asked for.

sudo ./host/install-garage-firewall.sh     # idempotent; loads + verifies
nft list table inet garage_guard           # counters prove traffic hit the guard

The Pi's ufw stays as-is (default deny incoming). Do not fold this table into a general host firewall — the Pi's ufw owns that, and moving k8s/wgportal/ DNS traffic here strands the cluster.

Apply / re-apply

Files installed, then compose up:

# on the Pi, from a checkout of sirius/homek8s
cd infrastructure/garage
sudo install -d -m 0755 /etc/garage
sudo install -m 0644 garage.toml         /etc/garage/garage.toml
sudo install -m 0644 docker-compose.yml  /etc/garage/docker-compose.yml

# one-time: the RPC secret is not in git
printf 'GARAGE_RPC_SECRET=%s\n' "$(openssl rand -hex 32)" | sudo tee /etc/garage/garage.env
sudo chmod 0600 /etc/garage/garage.env

cd /etc/garage && sudo docker compose up -d

docker compose up -d recreates the container in place; meta/ and data/ are bind mounts, so the node identity and every bucket survive.

Verify (all three must hold):

ss -ltnp | grep -E '390[0-3]'          # only 10.10.0.1 + 127.0.0.1, never 0.0.0.0
sudo docker exec garage /garage -c /etc/garage.toml status     # same node ID, HEALTHY
curl -s -o /dev/null -w '%{http_code}\n' http://10.10.0.1:3900/  # 403 (auth enforced)
curl -s -o /dev/null -w '%{http_code}\n' http://10.10.0.1:3903/metrics  # 200

The RPC secret is safe to regenerate on a fresh host: with a single node there is no peer to authenticate against. If the node is ever joined to a second one, the secret must match on both and must come from the backup, not from git.

Keys — one per consumer

Key material is never committed and never printed. Key IDs and scopes:

Key ID Name Scope Consumer
GK751dab7d7d535f49d060adfb ci-push W on siriusdevops-media sirius/siriusdevops CI media upload (Forgejo secrets GARAGE_ACCESS_KEY / GARAGE_SECRET_KEY)
GK633f87c796ae91585cca2303 site-fetch R on siriusdevops-media siriusdevops-site initContainer (Secret siriusdevops/garage-media-s3)
GK0e3b3c6f07813bc3002adb94 sirius-growth-blog RW sirius-growth-blog-media blog pipeline
GK50cccc3f680384d1d8d2db50 sirius-growth-ci RWO sirius-growth-photos, RW siriusdevops-media sirius-growth deploy-site.yml photo sync (Forgejo secrets, repointed 2026-11-19)
GKb7800d139463b4190b28bde8 sirius-growth-portal RW sirius-growth-client-files portal client files

The legacy shared key ci-key (GKddc329c08c30d1332e109fd4) was deleted 2026-11-19, not rotated. It held RWO on sirius-growth-photos, RWO on piedmont-photos and RW on siriusdevops-media, and it was the key the site initContainer was reading media with. Rotating in place would have meant deleting and re-creating the same over-broad grant, and a fresh credential with no consumer is just a live secret nobody uses. Its media grant is replaced by ci-push / site-fetch, its photos grant by sirius-growth-ci; no workflow in any repo still references piedmont-photos, so that grant was dropped rather than preserved. If something does turn out to need piedmont-photos, mint a scoped key (key create + bucket allow --read|--write) instead of resurrecting a shared one.

ci-push is W only, which is why the site repo's media step is aws s3 cp --recursive, not aws s3 sync: sync calls ListObjectsV2 and Garage answers 403 Forbidden: Operation is not allowed for this key without R. A write-only key that can secretly read is not write-only.

Create a key and grant exactly one bucket:

sudo docker exec garage /garage -c /etc/garage.toml key create site-fetch --yes
sudo docker exec garage /garage -c /etc/garage.toml bucket allow --read siriusdevops-media --key site-fetch
sudo docker exec garage /garage -c /etc/garage.toml key info site-fetch   # confirm scope

Removed: what and why

  • [s3_web] / port 3902 (static website mode) — removed 2026-11-19. It was published on 127.0.0.1 only, so a pod could never reach it (a pod's 127.0.0.1 is its own netns); public site serving is the Cilium Gateway on siriussec. Its only remaining effect was to tempt bucket publicity, which is what pushed sirius-growth to bake photos into the image. The initContainer sync replaced that need. Re-adding it means publishing a port and re-deciding bucket publicity — don't do that casually.
  • port 3901 (RPC) publish — removed. Single node: nothing outside the container speaks RPC. Garage's own CLI still uses loopback inside the container namespace.
  • rpc_secret in the config file — moved to GARAGE_RPC_SECRET in /etc/garage/garage.env so the committed config carries no credential.

Backup — nightly off the Pi

backup/garage-backup.sh meta|data, driven by two systemd timers:

Unit Schedule What
garage-meta-backup.{service,timer} hourly (+≤5 min jitter) garage meta snapshot (consistent copy of db.sqlite while running) + cluster_layout, data_layout, node_key, garage.toml, garage.env
garage-data-backup.{service,timer} nightly 03:30 (+≤10 min jitter) rsync -a --delete of data/

Destination is [email protected]:/root/garage-backup/ — the Linode VPS, reached over the wg-remote tunnel with the Pi's ~/.ssh/linode_admin key. It is off the Pi, in another power and internet domain. A bucket that backs up into itself is not a backup.

sudo install -m 0755 backup/garage-backup.sh /usr/local/sbin/garage-backup.sh
sudo install -m 0644 backup/garage-meta-backup.service backup/garage-meta-backup.timer \
                     backup/garage-data-backup.service backup/garage-data-backup.timer \
                     /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now garage-meta-backup.timer garage-data-backup.timer
sudo systemctl start garage-meta-backup.service    # prove it once by hand
journalctl -u garage-meta-backup.service -n 30 --no-pager

What is not covered by any other job: nothing in this cluster backs up Forgejo or the Postgres PVCs today — there is no backup CronJob in apps/base/forgejo/, only the nightly prune. So Garage's backup is not "added to" an existing one; it is the first backup job the platform has, and Forgejo/PG remain uncovered (a separate card).

Restore

Rebuilding the Pi, or recovering from a lost meta/:

# 1. get the tree back
sudo install -d -m 0755 /etc/garage
sudo install -d /home/sirius/websites/garage/{meta,data}
sudo rsync -a [email protected]:/root/garage-backup/meta/  /home/sirius/websites/garage/meta/
sudo rsync -a [email protected]:/root/garage-backup/data/  /home/sirius/websites/garage/data/

# 2. newest consistent metadata snapshot becomes the live db
sudo cp /home/sirius/websites/garage/meta/snapshots/<newest>/db.sqlite \
        /home/sirius/websites/garage/meta/db.sqlite
sudo rm -f /home/sirius/websites/garage/meta/db.sqlite-shm \
           /home/sirius/websites/garage/meta/db.sqlite-wal
sudo chown -R root:root /home/sirius/websites/garage/meta

# 3. restore config + secret (both are in the backup)
sudo install -m 0644 /root/garage-backup/meta/garage.toml /etc/garage/garage.toml
sudo install -m 0600 /root/garage-backup/meta/garage.env  /etc/garage/garage.env
sudo install -m 0644 docker-compose.yml                   /etc/garage/docker-compose.yml

# 4. bring it up and verify
cd /etc/garage && sudo docker compose up -d
sudo docker exec garage /garage -c /etc/garage.toml status     # node ID must match d053db4dfc97bf78
sudo docker exec garage /garage -c /etc/garage.toml bucket list

meta/ is the piece that orphans data/: the object bytes are useless without the metadata DB that maps keys to block refs. Losing data/ alone loses objects but leaves a consistent store. node_key must be restored with meta/ or the node comes back with a new identity and the layout no longer matches.

Key material is not in the backup. S3 keys live only in Garage's metadata (meta/), so a restore that keeps meta/ keeps the existing keys — no secret re-issue needed. A restore that rebuilds meta/ from scratch must recreate ci-push / site-fetch and update the k8s Secret and the Forgejo secrets.

Metrics

/metrics is served by the admin API and published on 10.10.0.1:3903 only (no metrics_token — the port does not leave the mesh). Scrape config, the garage Service/EndpointSlice and the alert rules live in monitoring/controllers/home/garage.yaml (that one is GitOps, via Flux).

Alerts: GarageDown, GarageClusterUnhealthy, GarageDiskFillingUp (>80%), GarageMetadataGcBacklog, GarageResyncErroredBlocks. There is no Alertmanager in this stack — they surface in Prometheus → /alerts and Grafana → Alerting.

Guardrails

  • Never make a bucket public. Never add a Cloudflare tunnel or DNS record.
  • Never publish the website listener.
  • Never publish a port on 0.0.0.0 "because it's only temporary".
  • Do not migrate Garage into Kubernetes on a hardening pass — see the top.