diff --git a/apps/base/siriusdevops/kustomization.yaml b/apps/base/siriusdevops/kustomization.yaml index aa601cb..742b5df 100644 --- a/apps/base/siriusdevops/kustomization.yaml +++ b/apps/base/siriusdevops/kustomization.yaml @@ -7,4 +7,3 @@ resources: - service-site.yaml - service-api.yaml - httproute.yaml - - networkpolicy-site-egress.yaml diff --git a/apps/base/siriusdevops/networkpolicy-site-egress.yaml b/apps/base/siriusdevops/networkpolicy-site-egress.yaml deleted file mode 100644 index 389e5c8..0000000 --- a/apps/base/siriusdevops/networkpolicy-site-egress.yaml +++ /dev/null @@ -1,70 +0,0 @@ -# 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 diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index f7b7ac4..9338bc2 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -296,20 +296,16 @@ Neither hostname is in the cloudflared ingress list, and `*.lab.internal` resolv | Property | Value | |---|---| -| Where | **Docker container on `rpi`**, not in Kubernetes — image `dxflrs/garage:v1.1.0`, container `garage` | -| Compose | **`infrastructure/garage/` in this repo** (installed to `/etc/garage/docker-compose.yml`); state stays at `/home/sirius/websites/garage/`. Flux does not apply it — see that directory's README | -| State | `data/` (bind → `/data/data`) and `meta/` (bind → `/data/meta`); config `/etc/garage/garage.toml`, RPC secret `/etc/garage/garage.env` (0600, not in git) | -| Ports | `10.10.0.1:3900` S3 API and `10.10.0.1:3903` metrics (WireGuard only), `127.0.0.1:3900` host-local. No `0.0.0.0` publish. 3901 (RPC) and 3902 (`[s3_web]`) are no longer published at all | -| Firewall | `host/garage-firewall.nft` — nftables PREROUTING priority -140 drop for 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 | -| Capacity | 100 GB configured; `354.3 GB (36.0%)` data available (single healthy node `d053db4dfc97bf78`) | -| Buckets | `sirius-growth-photos`, `piedmont-photos`, `siriusdevops-media`, `sirius-growth-blog-media`, `sirius-growth-client-files` | -| Keys | one per consumer — `ci-push` (W only) and `site-fetch` (R only) on `siriusdevops-media`; the shared `ci-key` was deleted 2026-11-19 | -| Backup | hourly `meta` snapshot + nightly `data` rsync to `root@10.20.0.1:/root/garage-backup` (systemd timers) | -| Metrics | Prometheus target `job="garage"` scraping `10.10.0.1:3903`, `monitoring/controllers/home/garage.yaml` | +| Where | **Docker container on `rpi`**, not in Kubernetes — image `dxflrs/garage:v1.1.0`, container `garage`, up 7 days | +| Compose | `/home/sirius/websites/garage/` (not under `/opt`) | +| State | `data/` (bind → `/data/data`) and `meta/` (bind → `/data/meta`); config `garage.toml` → `/etc/garage.toml` | +| Ports | `127.0.0.1:3900` S3 API, `127.0.0.1:3901` RPC, `127.0.0.1:3902` web/static — **plus `10.10.0.1:3900` on the WireGuard hub address** | +| Capacity | 100 GB configured; `401.3 GB (40.8%)` data available (single healthy node `d053db4dfc97bf78`) | +| Buckets | `sirius-growth-photos`, `piedmont-photos`, `sirius-growth-client-files` | -**Exposure model:** every published port binds an explicit address, and the host firewall drops the rest before Docker can rewrite the packet. A pod on siriussec reaches the S3 API at `http://10.10.0.1:3900` over the mesh; the LAN and the internet see nothing (measured off-mesh from the Linode node: all of 3900-3903 filtered). +**Correcting a carried-over claim:** Garage is **not** loopback-only. Three of its four published ports are loopback-bound, but the S3 API at `:3900` is *also* published on `10.10.0.1`, the Pi's WireGuard address. A pod on siriussec can therefore reach Garage's S3 API at `http://10.10.0.1:3900` over the mesh — but **not** the website port, which is `127.0.0.1:3902` only. -**What breaks:** anything that assumes `127.0.0.1:3902` (the removed static web endpoint) is reachable from inside the pod network. It never was — a pod's `127.0.0.1` is its own netns — and the listener is now gone. Kubernetes workloads must use the `10.10.0.1:3900` S3 endpoint, or the in-image `/photos/` alias baked into the site images as a fallback. That alias is a deliberate fallback, **not** evidence the bucket is gone. +**What breaks:** anything that assumes `127.0.0.1:3902` (the static web endpoint) is reachable from inside the pod network. It is not — a pod's `127.0.0.1` is its own netns. Kubernetes workloads must use the `10.10.0.1:3900` S3 endpoint, or the in-image `/photos/` alias baked into the site images as a fallback. That alias is a deliberate fallback, **not** evidence the bucket is gone. --- @@ -528,7 +524,7 @@ Host disks *(live)*: siriussec `/` 214 G, 141 G used (**70%**, 62 G free); rpi ` | `linode` tainted `dedicated=network:PreferNoSchedule` | label present, **no taint** (same for rpi) | | Public origin `10.10.0.5:8080` in the older paragraph | origin is **`10.10.0.2:8080`** (the skill's newer paragraph is right; the older one is stale) | | Gateway listener on `10.10.0.5` / one Gateway | Gateway `public` advertises **three** addresses (`.1/.2/.5`) but only `.2:8080` completes requests; a second Gateway `internal:8081` exists | -| Garage: systemd unit, loopback only | **Docker container** `dxflrs/garage:v1.1.0`; `10.10.0.1:3900` (S3) + `10.10.0.1:3903` (metrics) + `127.0.0.1:3900`, nothing on `0.0.0.0`; compose now committed at `infrastructure/garage/` | +| Garage: systemd unit, loopback only | **Docker container** `dxflrs/garage:v1.1.0`; loopback on `3900-3902` **plus `10.10.0.1:3900`** (S3 is reachable from pods) | | wgportal is the peer manager on the Pi | **wgportal is not running** — dir + compose remain, no container, no unit; peers are edited manually | | "Only wgportal compose should stay on the Pi" | Pi also runs `registry`, `handyman-site`, `sirius-growth-site` containers | | PHS/piedmont pods pinned to `linode` | pinned to **siriussec** (`nodeSelector: kubernetes.io/hostname`) | @@ -569,7 +565,7 @@ All times 2026-10-26 UTC. `kubeconfig` on the Legion admin laptop → `https://1 | 23 | Cloudflare API `GET /accounts/…/cfd_tunnel` | `sirius home` healthy, 4 connections; `piedmontomesvc` tunnel inactive, 0 | | 24 | rpi: `docker ps -a` | garage, registry, handyman-site, sirius-growth-site up; **no wg-portal**; 5 exited `onionwire-ci-*` containers | | 25 | rpi: `docker exec garage /garage status` and `bucket list` | node `d053db4dfc97bf78` healthy, 3 buckets | -| 26 | rpi: `ss -ltnp \| grep 390` | `127.0.0.1:3900` **and `10.10.0.1:3900`/`:3903`** — no `0.0.0.0`, no 3901/3902 | +| 26 | rpi: `ss -ltnp \| grep 390` | `127.0.0.1:3900-3902` **and `10.10.0.1:3900`** | | 27 | rpi: `df -h`, `free -h`, `vcgencmd get_throttled` | 58% used; 7.9 GiB RAM; `throttled=0x0` | | 28 | siriussec: `wg show` | peer = Pi hub, `AllowedIPs 10.10.0.0/24, 10.244.0.0/16`, handshake 1 min | | 29 | siriussec: `sudo nft list table inet k8s-api` | lo / wg0 / `10.244.0.0/16` accept, else drop | diff --git a/infrastructure/garage/README.md b/infrastructure/garage/README.md deleted file mode 100644 index 90868ce..0000000 --- a/infrastructure/garage/README.md +++ /dev/null @@ -1,239 +0,0 @@ -# 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. - -```bash -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: - -```bash -# 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): - -```bash -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: - -```bash -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 **`root@10.20.0.1:/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. - -```bash -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/`: - -```bash -# 1. get the tree back -sudo install -d -m 0755 /etc/garage -sudo install -d /home/sirius/websites/garage/{meta,data} -sudo rsync -a root@10.20.0.1:/root/garage-backup/meta/ /home/sirius/websites/garage/meta/ -sudo rsync -a root@10.20.0.1:/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//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. diff --git a/infrastructure/garage/backup/garage-backup.sh b/infrastructure/garage/backup/garage-backup.sh deleted file mode 100644 index ea8688f..0000000 --- a/infrastructure/garage/backup/garage-backup.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -# Garage backup — meta (frequent) and data (nightly), copied OFF the Pi. -# -# garage-backup.sh meta # consistent metadata snapshot + layout + rpc env -# garage-backup.sh data # object data tree -# -# Destination is the Linode VPS (10.20.0.1) over the wg-remote tunnel, NOT the -# Pi and NOT a bucket in Garage. A bucket that backs up into itself is not a -# backup: losing meta/ or the disk loses the "backup" with it. -# -# Run as root (systemd unit does): node_key is 0600 root:root, and rsync needs -# to read the whole meta tree. The SSH key is the sirius user's linode_admin, -# readable by root. -# -# Restore procedure: see ../README.md. Exit code is the truth — the units are -# oneshot and `systemctl status garage-*-backup.service` shows the last result. -set -euo pipefail - -mode=${1:-} -case "$mode" in - meta|data) ;; - *) echo "usage: $0 meta|data" >&2; exit 2 ;; -esac - -GARAGE_DIR=/home/sirius/websites/garage -KEY=/home/sirius/.ssh/linode_admin -REMOTE=root@10.20.0.1 -DEST=/root/garage-backup -KEEP_LOCAL_SNAPSHOTS=14 - -# Host key: the Pi's root has no known_hosts entry for the VPN peer, and a -# rebuilt Pi would not have one either. accept-new pins it on first contact and -# still fails loudly if the key later changes. The transport is the WireGuard -# tunnel, so first contact is already authenticated at the network layer. -export RSYNC_RSH="ssh -i $KEY -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=20" - -log() { printf '%s %s\n' "$(date -u +%FT%TZ)" "$*"; } - -# Fail loudly and early if the tunnel/target is not there. A silent "backup ok" -# with the VPS unreachable is the failure mode this whole file exists to avoid. -log "target check: $(ssh -i "$KEY" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=20 "$REMOTE" 'hostname; df -h / | tail -1')" - -# rsync will not create the parent of a --delete target, so make the tree first. -ssh -i "$KEY" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new "$REMOTE" \ - "install -d -m 0700 $DEST $DEST/meta $DEST/meta/snapshots $DEST/data" - -case "$mode" in - meta) - # `meta snapshot` is Garage's supported consistent copy of db.sqlite while - # the server keeps running. Never rsync a live db.sqlite+wal by hand. - log "taking metadata snapshot" - docker exec garage /garage -c /etc/garage.toml meta snapshot --all - - # Prune local snapshots so /home does not fill with dailies. - mapfile -t snaps < <(find "$GARAGE_DIR/meta/snapshots" -mindepth 1 -maxdepth 1 -type d -printf '%T@ %p\n' \ - | sort -rn | awk '{print $2}') - if (( ${#snaps[@]} > KEEP_LOCAL_SNAPSHOTS )); then - log "pruning $(( ${#snaps[@]} - KEEP_LOCAL_SNAPSHOTS )) old local snapshot(s)" - printf '%s\0' "${snaps[@]:$KEEP_LOCAL_SNAPSHOTS}" | xargs -0 -r rm -rf - fi - - log "syncing metadata to $REMOTE:$DEST/meta" - rsync -a --delete "$GARAGE_DIR/meta/snapshots/" "$REMOTE:$DEST/meta/snapshots/" - # Layout + node identity + the RPC secret. Without node_key the restored - # node gets a new identity and meta/data no longer agree. - rsync -a "$GARAGE_DIR/meta/cluster_layout" \ - "$GARAGE_DIR/meta/data_layout" \ - "$GARAGE_DIR/meta/node_key" \ - "$REMOTE:$DEST/meta/" - install -d -m 0700 /etc/garage - rsync -a /etc/garage/garage.toml /etc/garage/garage.env "$REMOTE:$DEST/meta/" - ssh -i "$KEY" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new "$REMOTE" \ - "chmod 600 $DEST/meta/garage.env $DEST/meta/node_key" - ;; - - data) - log "syncing object data to $REMOTE:$DEST/data" - # --delete keeps the remote an exact mirror (deleted objects stay deleted). - # multipart/ is in-flight upload scratch and is deliberately not mirrored. - rsync -a --delete --exclude '/multipart/' \ - "$GARAGE_DIR/data/" "$REMOTE:$DEST/data/" - ;; -esac - -log "remote state after $mode backup:" -ssh -i "$KEY" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new "$REMOTE" \ - "du -sh $DEST/* 2>/dev/null; echo '--- newest meta snapshot ---'; ls -1dt $DEST/meta/snapshots/*/ 2>/dev/null | head -3" -log "OK" diff --git a/infrastructure/garage/backup/garage-data-backup.service b/infrastructure/garage/backup/garage-data-backup.service deleted file mode 100644 index 320e316..0000000 --- a/infrastructure/garage/backup/garage-data-backup.service +++ /dev/null @@ -1,17 +0,0 @@ -# /etc/systemd/system/garage-data-backup.service (rpi) -# -# Object data is 36 MB today; a nightly full rsync costs seconds. If that ever -# stops being true, switch to `rsync -a --delete` with a bandwidth cap rather -# than moving to incremental tooling — the tree is content-addressed and rsync -# already only transfers changed blocks. -[Unit] -Description=Garage object data -> Linode VPS (off the Pi) -After=docker.service network-online.target -Wants=network-online.target - -[Service] -Type=oneshot -ExecStart=/usr/local/sbin/garage-backup.sh data -TimeoutStartSec=2h -Nice=15 -IOSchedulingClass=idle diff --git a/infrastructure/garage/backup/garage-data-backup.timer b/infrastructure/garage/backup/garage-data-backup.timer deleted file mode 100644 index d6b35a4..0000000 --- a/infrastructure/garage/backup/garage-data-backup.timer +++ /dev/null @@ -1,12 +0,0 @@ -# /etc/systemd/system/garage-data-backup.timer (rpi) -[Unit] -Description=Nightly Garage object-data backup - -[Timer] -OnCalendar=*-*-* 03:30:00 -RandomizedDelaySec=600 -Persistent=true -Unit=garage-data-backup.service - -[Install] -WantedBy=timers.target diff --git a/infrastructure/garage/backup/garage-meta-backup.service b/infrastructure/garage/backup/garage-meta-backup.service deleted file mode 100644 index 6ef30a5..0000000 --- a/infrastructure/garage/backup/garage-meta-backup.service +++ /dev/null @@ -1,15 +0,0 @@ -# /etc/systemd/system/garage-meta-backup.service (rpi) -# -# Metadata is the piece that orphans data/ if lost, and it changes on every -# upload/key/bucket change — hence hourly, not nightly. -[Unit] -Description=Garage metadata snapshot -> Linode VPS (off the Pi) -After=docker.service network-online.target -Wants=network-online.target - -[Service] -Type=oneshot -ExecStart=/usr/local/sbin/garage-backup.sh meta -# Slow tunnel is not a reason to retry a 5-minute job forever. -TimeoutStartSec=15min -Nice=10 diff --git a/infrastructure/garage/backup/garage-meta-backup.timer b/infrastructure/garage/backup/garage-meta-backup.timer deleted file mode 100644 index c7a43aa..0000000 --- a/infrastructure/garage/backup/garage-meta-backup.timer +++ /dev/null @@ -1,13 +0,0 @@ -# /etc/systemd/system/garage-meta-backup.timer (rpi) -[Unit] -Description=Hourly Garage metadata backup - -[Timer] -OnCalendar=hourly -# Spread off the hour so it does not race the Forgejo/registry work on the same box. -RandomizedDelaySec=300 -Persistent=true -Unit=garage-meta-backup.service - -[Install] -WantedBy=timers.target diff --git a/infrastructure/garage/docker-compose.yml b/infrastructure/garage/docker-compose.yml deleted file mode 100644 index e8cff27..0000000 --- a/infrastructure/garage/docker-compose.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Garage — private object store on the Pi -# -# NOT Flux-managed. Flux watches ./clusters/homek8s and none of it references -# this directory; the container is applied on rpi by hand (see README.md). -# The point of committing it is reproducibility: a rebuilt Pi comes back from -# this directory plus a backup. -# -# Installed to /etc/garage/docker-compose.yml (root:root 0644). State stays on -# the existing bind mounts under /home/sirius/websites/garage/ so this file can -# replace the old in-place definition without moving a byte of data. -# -# Exposure rule: every port is published on an EXPLICIT address. There is no -# 0.0.0.0 publish anywhere. 10.10.0.1 is the WireGuard hub address (the mesh), -# 127.0.0.1 is the Pi itself. Docker scopes a specific-IP publish to that -# destination only, so the LAN (192.168.1.125) and anything public stay closed -# even before the host firewall in host/garage-firewall.nft is considered. - -name: garage - -services: - garage: - image: dxflrs/garage:v1.1.0 - container_name: garage - restart: unless-stopped - - # GARAGE_RPC_SECRET. 0640 root:root, never in git. Single node: the value - # only authenticates RPC between Garage nodes, and there are none — a fresh - # `openssl rand -hex 32` is a valid restore value. - env_file: - - /etc/garage/garage.env - - command: ["/garage", "-c", "/etc/garage.toml", "server"] - - ports: - # S3 API over the WireGuard mesh. This is the only endpoint anything in - # the cluster uses (site media sync in, CI sync out). - - "10.10.0.1:3900:3900" - # Prometheus /metrics over the mesh (see monitoring/controllers/home/garage.yaml). - - "10.10.0.1:3903:3903" - # Host-local S3 for backup verification / manual `garage` CLI work on the - # Pi itself. Loopback only. - - "127.0.0.1:3900:3900" - - volumes: - - /etc/garage/garage.toml:/etc/garage.toml:ro - - /home/sirius/websites/garage/meta:/data/meta - - /home/sirius/websites/garage/data:/data/data - - logging: - driver: json-file - options: - max-size: "10m" - max-file: "3" diff --git a/infrastructure/garage/garage.toml b/infrastructure/garage/garage.toml deleted file mode 100644 index 93f202a..0000000 --- a/infrastructure/garage/garage.toml +++ /dev/null @@ -1,42 +0,0 @@ -# Garage v1.1.0 configuration — single node, rpi (10.10.0.1 on the WG mesh). -# -# Installed to /etc/garage/garage.toml (root:root 0644). -# -# Addresses here are INSIDE the container network namespace. What the host -# actually exposes is decided by docker-compose.yml (explicit 10.10.0.1 / 127.0.0.1 -# publishes), and enforced a second time by host/garage-firewall.nft. A 0.0.0.0 -# listener in this file is therefore not a public exposure. -# -# rpc_secret is NOT in this file: it is supplied as GARAGE_RPC_SECRET from -# /etc/garage/garage.env (0600, out of git). Verified on Garage v1.1.0 — -# the env var overrides the missing config key and the node starts normally. - -metadata_dir = "/data/meta" -data_dir = "/data/data" -db_engine = "sqlite" -replication_factor = 1 - -# RPC. Single node: nothing connects from outside the container, so the host -# publishes nothing for 3901. Garage still needs the listener for its own -# CLI-over-loopback calls (`garage status`, `garage key ...`). -rpc_bind_addr = "0.0.0.0:3901" -rpc_public_addr = "127.0.0.1:3901" - -[s3_api] -s3_region = "garage" -api_bind_addr = "0.0.0.0:3900" - -# Admin API + Prometheus metrics. Published on 10.10.0.1:3903 only. -# No metrics_token: the listener is WireGuard-only, and Prometheus runs in the -# cluster on the far side of the mesh. Add `metrics_token` here (and a matching -# bearer token in the ServiceMonitor) if 3903 ever leaves the mesh. -[admin] -api_bind_addr = "0.0.0.0:3903" - -# [s3_web] REMOVED 2026-11-19 (port 3902, static website mode). -# Nothing consumed it: a pod's 127.0.0.1 is its own netns, so 127.0.0.1:3902 was -# unreachable from the cluster, and public website serving is Cilium Gateway on -# siriussec (10.10.0.2:8080). The site now pulls media from the private bucket -# with an initContainer (`aws s3 sync` -> /media), so the web listener had no -# remaining consumer. Re-adding it means publishing a port and re-deciding -# bucket publicity — do not do that casually. diff --git a/infrastructure/garage/host/garage-firewall.nft b/infrastructure/garage/host/garage-firewall.nft deleted file mode 100644 index 4f8cc61..0000000 --- a/infrastructure/garage/host/garage-firewall.nft +++ /dev/null @@ -1,41 +0,0 @@ -#!/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 - } -} diff --git a/infrastructure/garage/host/garage-firewall.service b/infrastructure/garage/host/garage-firewall.service deleted file mode 100644 index 3f9ce7e..0000000 --- a/infrastructure/garage/host/garage-firewall.service +++ /dev/null @@ -1,25 +0,0 @@ -# /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 diff --git a/infrastructure/garage/host/install-garage-firewall.sh b/infrastructure/garage/host/install-garage-firewall.sh deleted file mode 100644 index 7f41779..0000000 --- a/infrastructure/garage/host/install-garage-firewall.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 diff --git a/monitoring/controllers/home/garage.yaml b/monitoring/controllers/home/garage.yaml deleted file mode 100644 index fa10181..0000000 --- a/monitoring/controllers/home/garage.yaml +++ /dev/null @@ -1,163 +0,0 @@ -# Garage (Pi, WireGuard-only object store) -> Prometheus -# -# Garage runs OUTSIDE the cluster (Docker on rpi, see infrastructure/garage/), -# so it has no pod to scrape. Its admin API serves /metrics on the Pi's -# WireGuard hub address 10.10.0.1:3903, which the cluster reaches over the mesh -# by native routing — the same path the site's media initContainer already uses -# for 10.10.0.1:3900. -# -# Service + EndpointSlice with no selector is the supported way to scrape a -# fixed external address with ServiceMonitor: the operator resolves endpoints -# from the Service's EndpointSlices, so there is nothing for the cluster to -# schedule and no node affinity problem. -# -# Before 2026-11-19 the admin port was published on loopback only, so /metrics -# returned "connection refused" from inside the cluster and Garage was invisible -# to Prometheus. The listener is now published on 10.10.0.1 only (never -# 0.0.0.0), with no metrics_token because the port does not leave the mesh. -# -# No Alertmanager is deployed in this stack: these rules show up under -# Prometheus -> /alerts and Grafana -> Alerting, they do not page anyone. ---- -apiVersion: v1 -kind: Service -metadata: - name: garage - namespace: monitoring - labels: - app: garage -spec: - type: ClusterIP - # No selector on purpose — the endpoints are static, not pods. - ports: - - name: metrics - port: 3903 - targetPort: 3903 - protocol: TCP ---- -apiVersion: discovery.k8s.io/v1 -kind: EndpointSlice -metadata: - name: garage - namespace: monitoring - labels: - app: garage - kubernetes.io/service-name: garage -addressType: IPv4 -ports: - - name: metrics - port: 3903 - protocol: TCP -endpoints: - - addresses: - - 10.10.0.1 - conditions: - ready: true ---- -apiVersion: v1 -kind: Endpoints -metadata: - # Kept for older tooling that still reads the Endpoints API; the EndpointSlice - # above is what the operator actually consumes on this cluster. - name: garage - namespace: monitoring - labels: - app: garage -subsets: - - addresses: - - ip: 10.10.0.1 - ports: - - name: metrics - port: 3903 - protocol: TCP ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - name: garage - namespace: monitoring - labels: - release: kube-prometheus-stack -spec: - jobLabel: app - namespaceSelector: - matchNames: - - monitoring - selector: - matchLabels: - app: garage - endpoints: - - port: metrics - path: /metrics - interval: 30s - scrapeTimeout: 10s ---- -apiVersion: monitoring.coreos.com/v1 -kind: PrometheusRule -metadata: - name: garage - namespace: monitoring - labels: - release: kube-prometheus-stack -spec: - groups: - - name: garage - rules: - - alert: GarageDown - expr: up{job="garage"} == 0 - for: 5m - labels: - severity: critical - annotations: - summary: "Garage metrics endpoint is down (10.10.0.1:3903)" - description: >- - Prometheus cannot scrape Garage. Either the container is stopped - (docker compose on the Pi), the 3903 publish was lost, or the - WireGuard mesh is broken. The site's media initContainer degrades - gracefully when this happens, so nothing else will report it. - - alert: GarageClusterUnhealthy - expr: cluster_healthy{job="garage"} == 0 - for: 5m - labels: - severity: critical - annotations: - summary: "Garage reports an unhealthy cluster" - description: >- - Single storage node d053db4dfc97bf78 was not able to reach a - healthy state. S3 requests will fail until this clears. - - alert: GarageDiskFillingUp - # Same 80% threshold as this stack's other disk alerts. - expr: >- - (1 - (garage_local_disk_avail{job="garage"} / garage_local_disk_total{job="garage"})) > 0.8 - for: 15m - labels: - severity: warning - annotations: - summary: "Garage storage node is more than 80% full" - description: >- - The Pi's Garage data directory is filling up. Uploads start failing - hard at 100%; free space or raise the node capacity in Garage, - do not delete the meta/ directory. - - alert: GarageMetadataGcBacklog - expr: table_gc_todo_queue_length{job="garage"} > 1000 - for: 30m - labels: - severity: warning - annotations: - summary: "Garage metadata GC queue is backed up" - description: >- - The metadata engine has more than 1000 pending GC operations. This - is the early signal for a metadata problem, which is the failure - mode that orphans data/ — check `garage meta snapshot` and backups - are running before it becomes a restore. - - alert: GarageResyncErroredBlocks - expr: block_resync_errored_blocks{job="garage"} > 0 - for: 15m - labels: - severity: warning - annotations: - summary: "Garage has blocks that failed to resync" - description: >- - At least one data block could not be resynchronised on the storage - node. With replication_factor 1 there is no other copy, so this is - data at risk — verify the object is readable and check backups. diff --git a/monitoring/controllers/home/kustomization.yaml b/monitoring/controllers/home/kustomization.yaml index bb12166..e7c4414 100644 --- a/monitoring/controllers/home/kustomization.yaml +++ b/monitoring/controllers/home/kustomization.yaml @@ -7,7 +7,6 @@ resources: - release.yaml - httproute.yaml - gateway-probe.yaml - - garage.yaml - prune-alerts.yaml - dashboards configMapGenerator: