From 5273a993f2b38b031f68b255f4b19a136b01a2cf Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 2 Nov 2026 17:17:36 -0500 Subject: [PATCH 01/88] apps: pin every first-party site image to an immutable ref Replace ':latest' + imagePullPolicy: Always on all seven site images with a pinned tag (or digest) and IfNotPresent, so the image a Deployment runs is chosen by this repo and rolled by Flux, not by CI patching restartedAt. Every pin is the image that was already running, so the change is a no-op for visitors: each pinned tag's manifest/config digest equals the running pod's imageID (siriusdevops-* f0dde2f4, growth-site ea306b7, growth-portal d9e558c4, phs-site 5b590cd). sirius-growth-contact and phs-contact have no CI build path (no workflow has ever pushed anything but :latest for them), so they are pinned by @sha256: digest rather than inventing a pipeline; documented in docs/site-image-pinning.md along with the operator flow. --- apps/base/piedmont/deployment-api.yaml | 6 +- apps/base/piedmont/deployment.yaml | 4 +- apps/base/sirius-growth/deployment-api.yaml | 6 +- .../base/sirius-growth/deployment-portal.yaml | 4 +- apps/base/sirius-growth/deployment.yaml | 4 +- apps/base/siriusdevops/deployment-api.yaml | 4 +- apps/base/siriusdevops/deployment-site.yaml | 4 +- docs/site-image-pinning.md | 110 ++++++++++++++++++ 8 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 docs/site-image-pinning.md diff --git a/apps/base/piedmont/deployment-api.yaml b/apps/base/piedmont/deployment-api.yaml index f34ed5d..c6e643a 100644 --- a/apps/base/piedmont/deployment-api.yaml +++ b/apps/base/piedmont/deployment-api.yaml @@ -21,8 +21,10 @@ spec: kubernetes.io/hostname: siriussec containers: - name: contact-api - image: forgejo.siriusdevops.com/sirius/phs-contact:latest - imagePullPolicy: Always + # This contact API has no CI build path that publishes a tagged image + # (see docs/site-image-pinning.md), so it is pinned by digest. + image: forgejo.siriusdevops.com/sirius/phs-contact@sha256:da61fc7943881f801fe6201749c01e364df6475d2460d6d17c8a6b48009f0056 + imagePullPolicy: IfNotPresent command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"] ports: - containerPort: 8090 diff --git a/apps/base/piedmont/deployment.yaml b/apps/base/piedmont/deployment.yaml index 579cc52..7d6c735 100644 --- a/apps/base/piedmont/deployment.yaml +++ b/apps/base/piedmont/deployment.yaml @@ -21,8 +21,8 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/phs-site:latest - imagePullPolicy: Always + image: forgejo.siriusdevops.com/sirius/phs-site:5b590cddab6d7889fdd3c272255f28c4560e752e + imagePullPolicy: IfNotPresent ports: - containerPort: 80 name: http diff --git a/apps/base/sirius-growth/deployment-api.yaml b/apps/base/sirius-growth/deployment-api.yaml index 369f76e..df03f85 100644 --- a/apps/base/sirius-growth/deployment-api.yaml +++ b/apps/base/sirius-growth/deployment-api.yaml @@ -21,8 +21,10 @@ spec: kubernetes.io/hostname: siriussec containers: - name: contact-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-contact:latest - imagePullPolicy: Always + # This contact API has no CI build path that publishes a tagged image + # (see docs/site-image-pinning.md), so it is pinned by digest. + image: forgejo.siriusdevops.com/sirius/sirius-growth-contact@sha256:cba0a5c67fee639dea78b568cbdf5889b2c78cc2c9cf85b02964ce17d60aab31 + imagePullPolicy: IfNotPresent command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"] ports: - containerPort: 8090 diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index fa16d1d..33f763e 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,8 +21,8 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:latest - imagePullPolicy: Always + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:d9e558c4e0922d3ecd28214f7698ec0994170481 + imagePullPolicy: IfNotPresent ports: - containerPort: 8091 name: http diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index f884807..5a4dbec 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,8 +21,8 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:latest - imagePullPolicy: Always + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:ea306b73b0d7c9ae8c33393a420e6d1d452b802b + imagePullPolicy: IfNotPresent ports: - containerPort: 80 name: http diff --git a/apps/base/siriusdevops/deployment-api.yaml b/apps/base/siriusdevops/deployment-api.yaml index d1af0f2..43b5bba 100644 --- a/apps/base/siriusdevops/deployment-api.yaml +++ b/apps/base/siriusdevops/deployment-api.yaml @@ -21,8 +21,8 @@ spec: kubernetes.io/hostname: siriussec containers: - name: contact-api - image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:latest - imagePullPolicy: Always + image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13 + imagePullPolicy: IfNotPresent command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"] ports: - containerPort: 8090 diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 7fe6685..0bb6daa 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -21,8 +21,8 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:latest - imagePullPolicy: Always + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:f0dde2f48c8224fb80d801ecb0d155c93332dc13 + imagePullPolicy: IfNotPresent ports: - containerPort: 80 name: http diff --git a/docs/site-image-pinning.md b/docs/site-image-pinning.md new file mode 100644 index 0000000..8fd609d --- /dev/null +++ b/docs/site-image-pinning.md @@ -0,0 +1,110 @@ +# Site images: immutable sha tags pinned in git + +Every first-party site image runs from a **tag pinned in this repo** and is rolled +by Flux. CI builds and pushes `:` and prints the exact ref; the +operator copies that ref into the Deployment manifest. There are **no cluster +credentials in any site repo** — CI cannot roll a Deployment and cannot read a +kubeconfig. + +This replaces the old model (`:latest` + `imagePullPolicy: Always` + CI patching +`kubectl.kubernetes.io/restartedAt` through a `site-deployer` ServiceAccount +token). That path is gone: the SA/Role/RoleBinding were removed and the +`KUBE_CONFIG` action secrets deleted. + +## Operator flow + +1. Push to a site repo (or `workflow_dispatch` it). The workflow builds the + amd64 image, pushes `/:`, and ends with a + `### Pin this in sirius/homek8s …` step that prints the ref. It also pushes + `:latest`, but **nothing in the cluster reads `:latest`** — it is a + convenience pointer for humans only. +2. Edit the Deployment in `apps/base//deployment*.yaml`: + + ```yaml + image: forgejo.siriusdevops.com/sirius/: + imagePullPolicy: IfNotPresent + ``` + +3. Commit + push `master`, then force the Flux recheck (gitrepository **first**, + kustomization **second** — an `apps` annotate that still reports the previous + sha has not fetched the commit): + + ```bash + kubectl -n flux-system annotate gitrepository flux-system reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite + kubectl -n flux-system annotate kustomization apps reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite + ``` + +4. Verify: the pod template changed, so the Deployment rolls within ~1m and the + pod reports the pinned ref. + + ```bash + kubectl -n get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.containerStatuses[0].imageID}{"\n"}{end}' + ``` + + `imageID` must name `:` and carry the digest the registry returns for + that tag (`Docker-Content-Digest`, below). + +Rollback is `git revert` of the pin commit — Flux reconciles back in ~1m. + +## Why the site repos are not Flux sources + +The only `GitRepository` cluster-wide is `flux-system` → `sirius/homek8s`. Flux +owns the *manifests*; the site repos own only their image builds. The content +revision a visitor sees is therefore chosen by the tag committed here, not by +whatever CI pushed last. A site repo push alone changes nothing in the cluster. + +## Current pins + +| Namespace | Deployment | Image ref | +|---|---|---| +| siriusdevops | siriusdevops-site | `siriusdevops-site:f0dde2f48c8224fb80d801ecb0d155c93332dc13` | +| siriusdevops | siriusdevops-contact | `siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13` | +| sirius-growth | sirius-growth-site | `sirius-growth-site:ea306b73b0d7c9ae8c33393a420e6d1d452b802b` | +| sirius-growth | sirius-growth-portal | `sirius-growth-portal:d9e558c4e0922d3ecd28214f7698ec0994170481` | +| sirius-growth | sirius-growth-contact | `sirius-growth-contact@sha256:cba0a5c67fee639dea78b568cbdf5889b2c78cc2c9cf85b02964ce17d60aab31` | +| piedmont | piedmont-site | `phs-site:5b590cddab6d7889fdd3c272255f28c4560e752e` | +| piedmont | piedmont-contact | `phs-contact@sha256:da61fc7943881f801fe6201749c01e364df6475d2460d6d17c8a6b48009f0056` | + +Each pin was chosen as the tag whose manifest is **the image already running** +(identical config digest), so pinning was a no-op for visitors. + +### The two digest-pinned contact APIs + +`sirius-growth-contact` and `phs-contact` have **no CI build path**: neither +`sirius-growth/.forgejo/workflows/*` nor `sirius/websites/.forgejo/workflows/deploy-handyman.yml` +builds them (the source dirs `contact-api/` and `phs-contact-api/` exist, but no +workflow pushes them; the registry only ever held `:latest`). They were built by +hand before the workflows were trimmed. Per the no-invented-pipelines rule they +are pinned by `@sha256:` digest — immutable, but there is no tag for an operator +to bump. If a build step is ever added for them, move them to `:` like the +rest. Both deployments run the same image content their pods already ran. + +## Registry facts + +- Registry: `forgejo.siriusdevops.com` (Forgejo packages, `[packages] ENABLED = true`). +- Reads/writes need a `read:package` / `write:package` scoped token; the stored + `~/.git-credentials` oauth2 token is git-scoped and is rejected by `/v2/`. +- **Tags do not expire.** `package_cleanup_rule` has zero rows and `app.ini` has + no cleanup cron, so a pinned `:` stays resolvable. +- Prove a pin `T` for image `I` without pulling anything: + + ```bash + curl -s -u "sirius:$TOK" -H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json' \ + -D - -o /dev/null "https://forgejo.siriusdevops.com/v2/sirius/$I/manifests/$T" | grep -i docker-content-digest + ``` + +## Pitfalls + +- **`docker buildx imagetools create` (the `:latest` promote step) wraps a + single-arch image in an index**, so the `:latest` digest differs from the + `:` digest even though the content is identical. Compare the *config* + digest, or compare the running pod's digest to the `:` tag, never + `:latest` vs the sha tag. +- The amd64 runner's job image (`node:20-bullseye`) has no docker CLI, so the + site workflows download a static client each run. That download has been + observed to stall for the full 300s (`curl: (28) … 0 out of 0 bytes`) and fail + the run. It is transient — re-dispatch the workflow instead of debugging the + network. +- `runs-on` matters: site images are `linux/amd64` and only siriussec serves + them. Build them on `docker-amd64` / `deploy-arm64`, never on the arm64 + `docker` runner. From 41bacb90e44b5c79e7b5c41ec140fdb6c881cd1a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 2 Nov 2026 17:22:06 -0500 Subject: [PATCH 02/88] apps: retire the site-deployer ServiceAccount Nothing in CI holds cluster credentials any more: every site image is pinned by tag/digest in this repo and rolled by Flux, so the siriusdevops and sirius-growth 'site-deployer' SA/Role/RoleBinding are dead. Dropping them from the kustomizations lets Flux prune all six objects, which also revokes the 8760h tokens behind the KUBE_CONFIG action secrets (deleted separately, and only after the pins were verified live). piedmont never had a deployer.yaml: its CI identity (phs-site-deployer) was created out-of-band and is removed by hand in the same change. --- apps/base/sirius-growth/deployer.yaml | 34 ---------------------- apps/base/sirius-growth/kustomization.yaml | 1 - apps/base/siriusdevops/deployer.yaml | 34 ---------------------- apps/base/siriusdevops/kustomization.yaml | 1 - 4 files changed, 70 deletions(-) delete mode 100644 apps/base/sirius-growth/deployer.yaml delete mode 100644 apps/base/siriusdevops/deployer.yaml diff --git a/apps/base/sirius-growth/deployer.yaml b/apps/base/sirius-growth/deployer.yaml deleted file mode 100644 index 28a6fd0..0000000 --- a/apps/base/sirius-growth/deployer.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Deployer identity used by the sirius-growth site repo's CI to roll the -# Deployment after pushing a new image. Deliberately minimal: patch/get/list on -# deployments in this namespace only. The kubeconfig is a repo secret -# (KUBE_CONFIG) in sirius/sirius-growth; the token is minted with -# # kubectl -n sirius-growth create token site-deployer --duration=8760h -apiVersion: v1 -kind: ServiceAccount -metadata: - name: site-deployer - namespace: sirius-growth ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: site-deployer - namespace: sirius-growth -rules: - - apiGroups: ["apps"] - resources: ["deployments"] - verbs: ["get", "list", "patch"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: site-deployer - namespace: sirius-growth -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: site-deployer -subjects: - - kind: ServiceAccount - name: site-deployer - namespace: sirius-growth diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index 5fb5eaa..c408e84 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -9,6 +9,5 @@ resources: - service-api.yaml - service-portal.yaml - httproute.yaml - - deployer.yaml - cluster.yaml - podmonitor.yaml diff --git a/apps/base/siriusdevops/deployer.yaml b/apps/base/siriusdevops/deployer.yaml deleted file mode 100644 index 6f4ec1f..0000000 --- a/apps/base/siriusdevops/deployer.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Deployer identity used by the siriusdevops site repo's CI to roll the -# Deployments after pushing a new image. Deliberately minimal: patch/get/list on -# deployments in this namespace only. The kubeconfig is a repo secret -# (KUBE_CONFIG) in sirius/siriusdevops-contact; the token is minted with -# kubectl -n siriusdevops create token site-deployer --duration=8760h -apiVersion: v1 -kind: ServiceAccount -metadata: - name: site-deployer - namespace: siriusdevops ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: site-deployer - namespace: siriusdevops -rules: - - apiGroups: ["apps"] - resources: ["deployments"] - verbs: ["get", "list", "patch"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: site-deployer - namespace: siriusdevops -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: site-deployer -subjects: - - kind: ServiceAccount - name: site-deployer - namespace: siriusdevops diff --git a/apps/base/siriusdevops/kustomization.yaml b/apps/base/siriusdevops/kustomization.yaml index 29e6eb9..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 - - deployer.yaml From bbcf02e68af95e661c16c76e135f85b32ff40e8a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 2 Nov 2026 17:51:53 -0500 Subject: [PATCH 03/88] docs(site-image-pinning): record the buildx-from-dind fix and the real stall host --- docs/site-image-pinning.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/site-image-pinning.md b/docs/site-image-pinning.md index 8fd609d..b964b2d 100644 --- a/docs/site-image-pinning.md +++ b/docs/site-image-pinning.md @@ -101,10 +101,14 @@ rest. Both deployments run the same image content their pods already ran. digest, or compare the running pod's digest to the `:` tag, never `:latest` vs the sha tag. - The amd64 runner's job image (`node:20-bullseye`) has no docker CLI, so the - site workflows download a static client each run. That download has been - observed to stall for the full 300s (`curl: (28) … 0 out of 0 bytes`) and fail - the run. It is transient — re-dispatch the workflow instead of debugging the - network. + site workflows fetch the binaries each run — and both hosts have been observed + to stall for the full 300s (`curl: (28) … 0 out of 0 bytes`). The static docker + client tries `download.docker.com` then `mirrors.aliyun.com`; **buildx is copied + out of the `docker:27-dind` image the runner already holds** + (`docker create docker:27-dind` → `docker cp …/cli-plugins/docker-buildx`), + with the GitHub release URL only as a fallback. Before that change a + three-attempt retry of the GitHub CDN failed all three times inside a job + container while the same URL fetched fine outside one. - `runs-on` matters: site images are `linux/amd64` and only siriussec serves them. Build them on `docker-amd64` / `deploy-arm64`, never on the arm64 `docker` runner. From 5c6c8b71c056b22a107fc2d8e8f3fae3f7ee0433 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 2 Nov 2026 18:09:48 -0500 Subject: [PATCH 04/88] apps: re-pin the contact APIs to their new :sha tags Both contact APIs now have amd64 build+push pipelines: sirius-growth/.forgejo/workflows/deploy-contact.yml (contact-api/) and sirius/websites/.forgejo/workflows/deploy-phs-contact.yml (phs-contact-api/). Each printed the tag for its first run, so the @sha256: pins (which existed only because there was no build path) become ordinary : tags an operator can bump. docs/site-image-pinning.md: drop the 'no CI build path' section and record the two workflows in the pins table. --- apps/base/piedmont/deployment-api.yaml | 6 ++--- apps/base/sirius-growth/deployment-api.yaml | 6 ++--- docs/site-image-pinning.md | 30 ++++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/apps/base/piedmont/deployment-api.yaml b/apps/base/piedmont/deployment-api.yaml index c6e643a..32fc373 100644 --- a/apps/base/piedmont/deployment-api.yaml +++ b/apps/base/piedmont/deployment-api.yaml @@ -21,9 +21,9 @@ spec: kubernetes.io/hostname: siriussec containers: - name: contact-api - # This contact API has no CI build path that publishes a tagged image - # (see docs/site-image-pinning.md), so it is pinned by digest. - image: forgejo.siriusdevops.com/sirius/phs-contact@sha256:da61fc7943881f801fe6201749c01e364df6475d2460d6d17c8a6b48009f0056 + # Built and pushed by sirius/websites/.forgejo/workflows/deploy-phs-contact.yml + # as :$sha (see docs/site-image-pinning.md). + image: forgejo.siriusdevops.com/sirius/phs-contact:5035443abb62913362e416ab7030a64726886886 imagePullPolicy: IfNotPresent command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"] ports: diff --git a/apps/base/sirius-growth/deployment-api.yaml b/apps/base/sirius-growth/deployment-api.yaml index df03f85..7797954 100644 --- a/apps/base/sirius-growth/deployment-api.yaml +++ b/apps/base/sirius-growth/deployment-api.yaml @@ -21,9 +21,9 @@ spec: kubernetes.io/hostname: siriussec containers: - name: contact-api - # This contact API has no CI build path that publishes a tagged image - # (see docs/site-image-pinning.md), so it is pinned by digest. - image: forgejo.siriusdevops.com/sirius/sirius-growth-contact@sha256:cba0a5c67fee639dea78b568cbdf5889b2c78cc2c9cf85b02964ce17d60aab31 + # Built and pushed by sirius-growth/.forgejo/workflows/deploy-contact.yml + # as :$sha (see docs/site-image-pinning.md). + image: forgejo.siriusdevops.com/sirius/sirius-growth-contact:c9c9379ebceca6879d3bbeff1c2601b6484e87b0 imagePullPolicy: IfNotPresent command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"] ports: diff --git a/docs/site-image-pinning.md b/docs/site-image-pinning.md index b964b2d..6c25120 100644 --- a/docs/site-image-pinning.md +++ b/docs/site-image-pinning.md @@ -61,23 +61,27 @@ whatever CI pushed last. A site repo push alone changes nothing in the cluster. | siriusdevops | siriusdevops-contact | `siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13` | | sirius-growth | sirius-growth-site | `sirius-growth-site:ea306b73b0d7c9ae8c33393a420e6d1d452b802b` | | sirius-growth | sirius-growth-portal | `sirius-growth-portal:d9e558c4e0922d3ecd28214f7698ec0994170481` | -| sirius-growth | sirius-growth-contact | `sirius-growth-contact@sha256:cba0a5c67fee639dea78b568cbdf5889b2c78cc2c9cf85b02964ce17d60aab31` | +| sirius-growth | sirius-growth-contact | `sirius-growth-contact:c9c9379ebceca6879d3bbeff1c2601b6484e87b0` | | piedmont | piedmont-site | `phs-site:5b590cddab6d7889fdd3c272255f28c4560e752e` | -| piedmont | piedmont-contact | `phs-contact@sha256:da61fc7943881f801fe6201749c01e364df6475d2460d6d17c8a6b48009f0056` | +| piedmont | piedmont-contact | `phs-contact:5035443abb62913362e416ab7030a64726886886` | -Each pin was chosen as the tag whose manifest is **the image already running** -(identical config digest), so pinning was a no-op for visitors. +Each pin is the tag CI printed for the commit that was deployed. (The first six +pins were chosen as the tag whose manifest was **the image already running**, so +pinning was a no-op for visitors; the two contact APIs were re-pinned after +their pipelines first ran — same source, freshly built.) -### The two digest-pinned contact APIs +### Contact APIs -`sirius-growth-contact` and `phs-contact` have **no CI build path**: neither -`sirius-growth/.forgejo/workflows/*` nor `sirius/websites/.forgejo/workflows/deploy-handyman.yml` -builds them (the source dirs `contact-api/` and `phs-contact-api/` exist, but no -workflow pushes them; the registry only ever held `:latest`). They were built by -hand before the workflows were trimmed. Per the no-invented-pipelines rule they -are pinned by `@sha256:` digest — immutable, but there is no tag for an operator -to bump. If a build step is ever added for them, move them to `:` like the -rest. Both deployments run the same image content their pods already ran. +Both contact APIs now build in CI, on `docker-amd64`, tagging `:$sha` and +promoting `:latest` as a pointer only: + +| Repo | Workflow | `paths:` | Source | Image | +|---|---|---|---|---| +| `sirius-growth` (`master`) | `.forgejo/workflows/deploy-contact.yml` | `contact-api/**` | `contact-api/` | `sirius/sirius-growth-contact` | +| `sirius/websites` (`main`) | `.forgejo/workflows/deploy-phs-contact.yml` | `phs-contact-api/**` | `phs-contact-api/` | `sirius/phs-contact` | + +They used to be hand-built (`:latest` only) and therefore pinned by `@sha256:`. +A change to either API is now a push → printed `:` ref → bump the pin here. ## Registry facts From c2c7e8d9e789b425799e4b761c42f5b6ca7b2c4a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 12:21:24 -0500 Subject: [PATCH 05/88] apps(sirius-growth): pin the site to 37329e3 (alt-band alignment fix) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 5a4dbec..7d4792d 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:ea306b73b0d7c9ae8c33393a420e6d1d452b802b + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:37329e36c3a612f1207a60857e6c7688c10afe0a imagePullPolicy: IfNotPresent ports: - containerPort: 80 From d5193c25256d3954508d9f1d9200ae322f5e9a06 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 12:36:37 -0500 Subject: [PATCH 06/88] apps(sirius-growth): pin site c03101f3 (admin UI) and portal a150b6f3 (leads/password/remove) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- apps/base/sirius-growth/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index 33f763e..6c5cf47 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:d9e558c4e0922d3ecd28214f7698ec0994170481 + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:a150b6f3708c9ab7fc284045a0277f359bc5eb2c imagePullPolicy: IfNotPresent ports: - containerPort: 8091 diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 7d4792d..d162215 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:37329e36c3a612f1207a60857e6c7688c10afe0a + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:c03101f380eda827337d0cf01c74c58dffe26021 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 45c3b8533b3d66b9cdcbd6cd06eccc02b8451a16 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 12:46:27 -0500 Subject: [PATCH 07/88] apps(sirius-growth): sgs-leadgen weekly CronJob (ET) + monthly NCDA job + state PVC Runs the published amd64 image forgejo.../sgs-leadgen:eef9358 with DATABASE_URL from sirius-growth-portal-app and the contact bot's Telegram pair; /data on a local-path PVC pins to siriussec, /tmp on an emptyDir so the root fs stays RO. --- .../sirius-growth/cronjob-leadgen-ncda.yaml | 85 +++++++++++++++++++ apps/base/sirius-growth/cronjob-leadgen.yaml | 85 +++++++++++++++++++ apps/base/sirius-growth/kustomization.yaml | 3 + apps/base/sirius-growth/pvc-leadgen.yaml | 12 +++ 4 files changed, 185 insertions(+) create mode 100644 apps/base/sirius-growth/cronjob-leadgen-ncda.yaml create mode 100644 apps/base/sirius-growth/cronjob-leadgen.yaml create mode 100644 apps/base/sirius-growth/pvc-leadgen.yaml diff --git a/apps/base/sirius-growth/cronjob-leadgen-ncda.yaml b/apps/base/sirius-growth/cronjob-leadgen-ncda.yaml new file mode 100644 index 0000000..898e058 --- /dev/null +++ b/apps/base/sirius-growth/cronjob-leadgen-ncda.yaml @@ -0,0 +1,85 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: sgs-leadgen-ncda + namespace: sirius-growth +spec: + # 10:00, not 08:00: on a Monday-the-1st the weekly job owns the RWO volume at + # 08:00 and concurrencyPolicy is per-CronJob, so a 2h gap keeps them apart. + schedule: "0 10 1 * *" + timeZone: America/New_York + concurrencyPolicy: Forbid + startingDeadlineSeconds: 3600 + suspend: false + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + backoffLimit: 1 + activeDeadlineSeconds: 1800 + ttlSecondsAfterFinished: 604800 + template: + metadata: + labels: + app: sgs-leadgen-ncda + spec: + restartPolicy: Never + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + securityContext: + fsGroup: 10001 + containers: + - name: leadgen + image: forgejo.siriusdevops.com/sirius/sgs-leadgen:eef935874bb19b6cee73bd93d7fd9ab4001ec184 + imagePullPolicy: IfNotPresent + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: sirius-growth-portal-app + key: database-url + - name: TELEGRAM_BOT_TOKEN + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_TOKEN + - name: TELEGRAM_CHAT_ID + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_CHAT + - name: SGS_DATA_DIR + value: /data + - name: SGS_STATE_PATH + value: /data/state.json + - name: SGS_CSV + value: /data/leads.csv + # Monthly-only source: the NCDA&CS licensed-nursery register. + - name: SGS_NCDA + value: "1" + volumeMounts: + - name: data + mountPath: /data + - name: tmp + mountPath: /tmp + securityContext: + runAsNonRoot: true + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + volumes: + - name: data + persistentVolumeClaim: + claimName: sgs-leadgen-data + - name: tmp + emptyDir: + sizeLimit: 256Mi diff --git a/apps/base/sirius-growth/cronjob-leadgen.yaml b/apps/base/sirius-growth/cronjob-leadgen.yaml new file mode 100644 index 0000000..051bfca --- /dev/null +++ b/apps/base/sirius-growth/cronjob-leadgen.yaml @@ -0,0 +1,85 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: sgs-leadgen + namespace: sirius-growth +spec: + schedule: "0 8 * * 1" + timeZone: America/New_York + concurrencyPolicy: Forbid + startingDeadlineSeconds: 3600 + suspend: false + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + backoffLimit: 1 + activeDeadlineSeconds: 1800 + ttlSecondsAfterFinished: 604800 + template: + metadata: + labels: + app: sgs-leadgen + spec: + restartPolicy: Never + # local-path is a node-local volume: the pod must run where the PV is. + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + # local-path mounts root-owned; the image runs as uid 10001, so fsGroup + # makes /data group-writable for it. + securityContext: + fsGroup: 10001 + containers: + - name: leadgen + image: forgejo.siriusdevops.com/sirius/sgs-leadgen:eef935874bb19b6cee73bd93d7fd9ab4001ec184 + imagePullPolicy: IfNotPresent + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: sirius-growth-portal-app + key: database-url + - name: TELEGRAM_BOT_TOKEN + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_TOKEN + - name: TELEGRAM_CHAT_ID + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_CHAT + - name: SGS_DATA_DIR + value: /data + - name: SGS_STATE_PATH + value: /data/state.json + - name: SGS_CSV + value: /data/leads.csv + volumeMounts: + - name: data + mountPath: /data + # tempfile.NamedTemporaryFile() needs a writable TMPDIR; the rest + # of the root filesystem stays read-only. + - name: tmp + mountPath: /tmp + securityContext: + runAsNonRoot: true + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + volumes: + - name: data + persistentVolumeClaim: + claimName: sgs-leadgen-data + - name: tmp + emptyDir: + sizeLimit: 256Mi diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index c408e84..ab9f9d8 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -11,3 +11,6 @@ resources: - httproute.yaml - cluster.yaml - podmonitor.yaml + - pvc-leadgen.yaml + - cronjob-leadgen.yaml + - cronjob-leadgen-ncda.yaml diff --git a/apps/base/sirius-growth/pvc-leadgen.yaml b/apps/base/sirius-growth/pvc-leadgen.yaml new file mode 100644 index 0000000..a0fc253 --- /dev/null +++ b/apps/base/sirius-growth/pvc-leadgen.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: sgs-leadgen-data + namespace: sirius-growth +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 1Gi From 418f2c5fc004b585930f7bc07a33ea81ec1e7cfc Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 12:49:44 -0500 Subject: [PATCH 08/88] apps(sirius-growth): pin portal adbf227 (Cache-Control: no-store on /api/portal/*) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index 6c5cf47..864f011 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:a150b6f3708c9ab7fc284045a0277f359bc5eb2c + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:adbf22762dcd6cfab60a03d32b4d92c726b9e31e imagePullPolicy: IfNotPresent ports: - containerPort: 8091 From c77b5a6e80f829bb285d8f2d9fb8eb94154cc73b Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 13:13:42 -0500 Subject: [PATCH 09/88] apps(sirius-growth): pin site be32304 (js/css revalidate rule, narrowed to /js/ /css/) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index d162215..51fdaff 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:c03101f380eda827337d0cf01c74c58dffe26021 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:be32304a4cacbc779fcb1f7e5d65b85aed9be969 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 5036d853bfc253c9e43924be088687bcf62ae36b Mon Sep 17 00:00:00 2001 From: sirius Date: Tue, 3 Nov 2026 18:16:03 +0000 Subject: [PATCH 10/88] =?UTF-8?q?SGS=20portal:=20nginx=20login=20gate=20?= =?UTF-8?q?=E2=80=94=20rate-limit=20/api/portal/login=20(12r/m,=20burst=20?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sirius-growth/configmap-portal-gate.yaml | 69 +++++++++++++++++++ .../sirius-growth/deployment-portal-gate.yaml | 53 ++++++++++++++ apps/base/sirius-growth/httproute.yaml | 7 ++ apps/base/sirius-growth/kustomization.yaml | 3 + .../sirius-growth/service-portal-gate.yaml | 14 ++++ 5 files changed, 146 insertions(+) create mode 100644 apps/base/sirius-growth/configmap-portal-gate.yaml create mode 100644 apps/base/sirius-growth/deployment-portal-gate.yaml create mode 100644 apps/base/sirius-growth/service-portal-gate.yaml diff --git a/apps/base/sirius-growth/configmap-portal-gate.yaml b/apps/base/sirius-growth/configmap-portal-gate.yaml new file mode 100644 index 0000000..5e6a0b0 --- /dev/null +++ b/apps/base/sirius-growth/configmap-portal-gate.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: sirius-growth-portal-gate + namespace: sirius-growth +data: + default.conf: | + # Sirius Growth portal login gate. One job: cap credential attempts per client + # IP before they reach the API. The HTTPRoute sends only /api/portal/login* here + # (login, plus a trailing-slash variant); everything else goes straight to the + # portal service, so this pod can never break uploads, downloads or the admin API. + + # The TCP peer is always cluster ingress, so $remote_addr is meaningless until + # the forwarded chain is resolved: Envoy (hostNetwork, siriussec) appends the + # caller to X-Forwarded-For. Trusting the pod / service / node ranges makes + # $remote_addr the real client. A caller cannot spoof it by sending its own + # X-Forwarded-For, because Envoy appends the true address to the right of + # whatever the client supplied and nginx walks the chain from the right. + set_real_ip_from 10.244.0.0/16; + set_real_ip_from 10.96.0.0/12; + set_real_ip_from 10.10.0.0/24; + real_ip_header X-Forwarded-For; + real_ip_recursive on; + + # 12 attempts/min per IP with 6 in hand: a fat-fingered operator gets several + # tries, a password guesser gets nowhere. Tune the two numbers here only. + limit_req_zone $binary_remote_addr zone=portal_login:10m rate=12r/m; + limit_req_status 429; + limit_req_log_level warn; + + server { + listen 8080; + server_name _; + default_type application/json; + + client_max_body_size 8k; + client_body_timeout 10s; + + location ^~ /api/portal/login { + limit_req zone=portal_login burst=6 nodelay; + + # JSON, not nginx's HTML error page: portal.js shows the body's `error` + # string on the sign-in page instead of "Portal API is not reachable". + error_page 429 @login_limited; + + proxy_pass http://sirius-growth-portal:8091; + proxy_http_version 1.1; + proxy_set_header Host $host; + # Pass the chain through verbatim; uvicorn reads the leftmost entry. + proxy_set_header X-Forwarded-For $http_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_connect_timeout 5s; + proxy_read_timeout 15s; + proxy_send_timeout 15s; + proxy_buffering off; + } + + location @login_limited { + internal; + default_type application/json; + add_header Cache-Control "no-store" always; + return 429 '{"error":"too many sign-in attempts - wait a minute and try again"}'; + } + + # Nothing else is routed to this pod. An honest 404 beats a proxied surprise. + location / { + return 404; + } + } diff --git a/apps/base/sirius-growth/deployment-portal-gate.yaml b/apps/base/sirius-growth/deployment-portal-gate.yaml new file mode 100644 index 0000000..32714f6 --- /dev/null +++ b/apps/base/sirius-growth/deployment-portal-gate.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sirius-growth-portal-gate + namespace: sirius-growth +spec: + replicas: 1 + selector: + matchLabels: + app: sirius-growth-portal-gate + template: + metadata: + labels: + app: sirius-growth-portal-gate + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: nginx + image: nginx:1.27-alpine + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 + name: http + volumeMounts: + - name: conf + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf + readOnly: true + readinessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 2 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 20 + resources: + requests: + cpu: 10m + memory: 16Mi + limits: + memory: 64Mi + volumes: + - name: conf + configMap: + name: sirius-growth-portal-gate diff --git a/apps/base/sirius-growth/httproute.yaml b/apps/base/sirius-growth/httproute.yaml index 07edc7b..4651c53 100644 --- a/apps/base/sirius-growth/httproute.yaml +++ b/apps/base/sirius-growth/httproute.yaml @@ -18,6 +18,13 @@ spec: backendRefs: - name: sirius-growth-contact port: 8090 + - matches: + - path: + type: PathPrefix + value: /api/portal/login + backendRefs: + - name: sirius-growth-portal-gate + port: 8080 - matches: - path: type: PathPrefix diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index ab9f9d8..b3e796c 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -5,9 +5,12 @@ resources: - deployment.yaml - deployment-api.yaml - deployment-portal.yaml + - deployment-portal-gate.yaml + - configmap-portal-gate.yaml - service.yaml - service-api.yaml - service-portal.yaml + - service-portal-gate.yaml - httproute.yaml - cluster.yaml - podmonitor.yaml diff --git a/apps/base/sirius-growth/service-portal-gate.yaml b/apps/base/sirius-growth/service-portal-gate.yaml new file mode 100644 index 0000000..4ceadee --- /dev/null +++ b/apps/base/sirius-growth/service-portal-gate.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: sirius-growth-portal-gate + namespace: sirius-growth +spec: + type: ClusterIP + selector: + app: sirius-growth-portal-gate + ports: + - name: http + port: 8080 + targetPort: 8080 + protocol: TCP From c2b502ba577176dfc4b0eaeb9c7ac6dbabe537c5 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 13:17:40 -0500 Subject: [PATCH 11/88] apps(sirius-growth): pin site db63ff1 (admin password 401 redirects to /signin?next=/admin) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 51fdaff..c6be183 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:be32304a4cacbc779fcb1f7e5d65b85aed9be969 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:db63ff1bb509c8e172b60cd2d5e31eec3d6f5b6f imagePullPolicy: IfNotPresent ports: - containerPort: 80 From b68b22288e78ae65520a00a978f2709296a92026 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 14:36:19 -0500 Subject: [PATCH 12/88] apps(sirius-growth): pin site ed3ca8f (root-check hook band + second diagnostics link) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index c6be183..e2b93c2 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:db63ff1bb509c8e172b60cd2d5e31eec3d6f5b6f + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:ed3ca8f8dbc75018991a45ffb55f1be1786ef910 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 6ca43350faa68625fd240313036aacbffe6f9054 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 19:44:33 -0500 Subject: [PATCH 13/88] apps(sirius-growth): pin portal f02cea9 + site b274454 (onboarding validation errors) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- apps/base/sirius-growth/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index 864f011..ebec782 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:adbf22762dcd6cfab60a03d32b4d92c726b9e31e + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:f02cea9fff84fc0e983a93efef3d23ef0fb10f0d imagePullPolicy: IfNotPresent ports: - containerPort: 8091 diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index e2b93c2..640504b 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:ed3ca8f8dbc75018991a45ffb55f1be1786ef910 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:b274454c2c1cecddb4d505a94a5f1453893e895e imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 695bd9044960aa40362f0ccec0c7dc162100f02e Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 20:38:59 -0500 Subject: [PATCH 14/88] apps(sirius-growth): pin portal bcdba9d (named zones per client) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index ebec782..6fd48cd 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:f02cea9fff84fc0e983a93efef3d23ef0fb10f0d + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:bcdba9d3da6ae7c8fd7b7e7a1a3d539d88b3c6fd imagePullPolicy: IfNotPresent ports: - containerPort: 8091 From a80d7e233f4b997392ccd2bd25d89e3ae9c552d9 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 21:14:54 -0500 Subject: [PATCH 15/88] apps(sirius-growth): pin portal 0f156d2 + site 0b4a8c0 (admin split, zones, messages, inline files) portal :0f156d2f17aab3461ba4c5d7d4d8988861b2b14b (deploy-portal run 87, success) carries the zones API (bcdba9d), inline file disposition and the last-message fields; registry digest sha256:90d9c89d...6643. site :0b4a8c0a27c35855eab03ebaa23a7ab5229245a8 (deploy-site run 90, success) is the admin split plus per-client zones/messages UI and the dashboard zone filter with inline previews, and gates /admin/leads + /admin/settings in all three nginx variants; registry digest sha256:ab680c5b...5adf. --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- apps/base/sirius-growth/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index 6fd48cd..de7b694 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:bcdba9d3da6ae7c8fd7b7e7a1a3d539d88b3c6fd + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:0f156d2f17aab3461ba4c5d7d4d8988861b2b14b imagePullPolicy: IfNotPresent ports: - containerPort: 8091 diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 640504b..33356e8 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:b274454c2c1cecddb4d505a94a5f1453893e895e + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:0b4a8c0a27c35855eab03ebaa23a7ab5229245a8 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From e4c7fd9ff7ecc68040d6919bd917cedf503a562d Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 21:33:01 -0500 Subject: [PATCH 16/88] apps(sirius-growth): pin site 040d3e1 (root-absolute admin CSS/JS) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit site :040d3e1d5c6bae57c7b4d5edd00b4a969bb8718d (deploy-site run 91, success) loads style.css/portal.css/portal.js root-absolute so /admin/leads and /admin/settings stop 404ing on /admin/css/… and /admin/js/… and the Leads table renders. Registry digest sha256:bd83baa6…ffcd. Portal pin untouched. --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 33356e8..9d82e82 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:0b4a8c0a27c35855eab03ebaa23a7ab5229245a8 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:040d3e1d5c6bae57c7b4d5edd00b4a969bb8718d imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 07caa865da8cbe924adb68c9b1f08eab7b574e7f Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 23:42:31 -0500 Subject: [PATCH 17/88] apps(sirius-growth): pin portal 540ca05 (phase 1 diagnostics API: input readings, zone targets, site baseline) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index de7b694..e489069 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:0f156d2f17aab3461ba4c5d7d4d8988861b2b14b + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:540ca05d5f0b562949fb305f9946f49a91a819ec imagePullPolicy: IfNotPresent ports: - containerPort: 8091 From 6cfa86d25d28e6f4a29cd43d9172cb745cd84dc5 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 23:42:31 -0500 Subject: [PATCH 18/88] apps(sirius-growth): pin site 1bdcdcd (phase 1 dashboard: baseline panel, target bands, readings table) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 9d82e82..fd4d93f 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:040d3e1d5c6bae57c7b4d5edd00b4a969bb8718d + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:1bdcdcd0068b90b6e890a398d03101daf0603c52 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From b7f5e0105d4b89ef78653e132b9d6dcece43dafe Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Wed, 4 Nov 2026 00:41:01 -0500 Subject: [PATCH 19/88] apps(sirius-growth): pin portal 71c7eec + site a72ea75 (phase 2: crew logging schema, thread attachments) portal-api: multipart message attachments with magic-byte sniffing, owner-checked GET /api/portal/attachments/{id}; measured_by/application logging with logged_by_role. site: crew self-logging forms, Specialist/Crew badges, photo picker + lazy inline thumbnails. --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- apps/base/sirius-growth/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index e489069..a6b5a15 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:540ca05d5f0b562949fb305f9946f49a91a819ec + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:71c7eec091ce28ffbc4683d4b504631f0f6ec1da imagePullPolicy: IfNotPresent ports: - containerPort: 8091 diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index fd4d93f..2702188 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:1bdcdcd0068b90b6e890a398d03101daf0603c52 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:a72ea75eed71202e18fed84e1c669c2dd808aa25 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 5a9400790c383f92821d77962c7e2d6196d288ad Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Wed, 4 Nov 2026 01:39:10 -0500 Subject: [PATCH 20/88] apps(sirius-growth): wire TG_TOKEN/TG_CHAT into the portal from sirius-growth-contact The portal-api image gained Telegram-only operator alerts (phase 3C) but reads TG_TOKEN/TG_CHAT at startup; unset, it logs one line and no-ops. Reuse the same bot and secret the contact service already uses - no new secret, no value in git. --- apps/base/sirius-growth/deployment-portal.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index a6b5a15..dce54f6 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -72,6 +72,16 @@ spec: secretKeyRef: name: sirius-growth-portal-app key: s3-region + - name: TG_TOKEN + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_TOKEN + - name: TG_CHAT + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_CHAT readinessProbe: httpGet: path: /api/portal/health From 1fb49c0507f14da956873b9dbdbd91782e9c055f Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Wed, 4 Nov 2026 01:39:11 -0500 Subject: [PATCH 21/88] apps(sirius-growth): pin portal efd5b61 + site 7d7fd4c (phase 3: action items, .ics feed, alerts, print view) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- apps/base/sirius-growth/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index dce54f6..006d6c1 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:71c7eec091ce28ffbc4683d4b504631f0f6ec1da + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:efd5b6183d082ec6b9526be73ed3906275a58fa1 imagePullPolicy: IfNotPresent ports: - containerPort: 8091 diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 2702188..661c8c3 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:a72ea75eed71202e18fed84e1c669c2dd808aa25 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:7d7fd4c0cf2aaaaafc9fceb65c3661ade3da1443 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From be8233079b1d7cfc1bcae6cf79dcb45f56592efa Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 5 Nov 2026 11:39:32 -0500 Subject: [PATCH 22/88] apps(sirius-growth): pin portal ce350ed + site 4285926 (calendar page, feed kind, application series) --- apps/base/sirius-growth/deployment-portal.yaml | 2 +- apps/base/sirius-growth/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/base/sirius-growth/deployment-portal.yaml b/apps/base/sirius-growth/deployment-portal.yaml index 006d6c1..fc7120a 100644 --- a/apps/base/sirius-growth/deployment-portal.yaml +++ b/apps/base/sirius-growth/deployment-portal.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: portal-api - image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:efd5b6183d082ec6b9526be73ed3906275a58fa1 + image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:ce350ed04749d57833020bda8604b1d16896d25c imagePullPolicy: IfNotPresent ports: - containerPort: 8091 diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 661c8c3..07e82ef 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:7d7fd4c0cf2aaaaafc9fceb65c3661ade3da1443 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:428592690bd7a3fecee7990a59119db4ff895079 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From aa71da2f31ee123ae814ef12e9152174bf7e9937 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 5 Nov 2026 13:07:26 -0500 Subject: [PATCH 23/88] apps(sirius-growth): blog Deployment/Service + pin site d44446c (journal mount) - deployment-blog.yaml / service-blog.yaml: blog FastAPI on 8092, siriussec, env from sirius-growth-blog-app + sirius-growth-blog-s3, PUBLIC_BASE_URL=https://siriusgrowthsolutions.com/journal. No HTTPRoute: the site nginx proxies /journal to this ClusterIP service. - deployment.yaml: site 4285926 -> d44446c (nginx /journal proxy, nav menu). - portal Deployment untouched. --- apps/base/sirius-growth/deployment-blog.yaml | 91 ++++++++++++++++++++ apps/base/sirius-growth/deployment.yaml | 2 +- apps/base/sirius-growth/kustomization.yaml | 2 + apps/base/sirius-growth/service-blog.yaml | 14 +++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 apps/base/sirius-growth/deployment-blog.yaml create mode 100644 apps/base/sirius-growth/service-blog.yaml diff --git a/apps/base/sirius-growth/deployment-blog.yaml b/apps/base/sirius-growth/deployment-blog.yaml new file mode 100644 index 0000000..65f227c --- /dev/null +++ b/apps/base/sirius-growth/deployment-blog.yaml @@ -0,0 +1,91 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sirius-growth-blog + namespace: sirius-growth +spec: + replicas: 1 + selector: + matchLabels: + app: sirius-growth-blog + template: + metadata: + labels: + app: sirius-growth-blog + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: blog + # Pinned by immutable tag. The blog is mounted at /journal by the + # site nginx, so it has no Service hostname of its own and no + # HTTPRoute - the marketing site proxies to this ClusterIP service. + image: forgejo.siriusdevops.com/sirius/sirius-growth-blog:d44446c87c5894de29739ee0bd25f40146148bd5 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8092 + name: http + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: sirius-growth-blog-app + key: database-url + - name: SESSION_SECRET + valueFrom: + secretKeyRef: + name: sirius-growth-blog-app + key: session-secret + - name: S3_ENDPOINT + valueFrom: + secretKeyRef: + name: sirius-growth-blog-s3 + key: endpoint + - name: S3_BUCKET + valueFrom: + secretKeyRef: + name: sirius-growth-blog-s3 + key: bucket + - name: S3_ACCESS_KEY + valueFrom: + secretKeyRef: + name: sirius-growth-blog-s3 + key: access-key + - name: S3_SECRET_KEY + valueFrom: + secretKeyRef: + name: sirius-growth-blog-s3 + key: secret-key + - name: S3_REGION + valueFrom: + secretKeyRef: + name: sirius-growth-blog-s3 + key: region + # Every URL the service emits (canonical, RSS, sitemap, media, + # admin form actions) hangs off this; the mount is /journal. + - name: PUBLIC_BASE_URL + value: https://siriusgrowthsolutions.com/journal + - name: PORTAL_BASE_URL + value: https://siriusgrowthsolutions.com + readinessProbe: + httpGet: + path: /health + port: 8092 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + httpGet: + path: /health + port: 8092 + initialDelaySeconds: 20 + periodSeconds: 20 + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 384Mi diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 07e82ef..ab34513 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:428592690bd7a3fecee7990a59119db4ff895079 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:d44446c87c5894de29739ee0bd25f40146148bd5 imagePullPolicy: IfNotPresent ports: - containerPort: 80 diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index b3e796c..af13e54 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -5,11 +5,13 @@ resources: - deployment.yaml - deployment-api.yaml - deployment-portal.yaml + - deployment-blog.yaml - deployment-portal-gate.yaml - configmap-portal-gate.yaml - service.yaml - service-api.yaml - service-portal.yaml + - service-blog.yaml - service-portal-gate.yaml - httproute.yaml - cluster.yaml diff --git a/apps/base/sirius-growth/service-blog.yaml b/apps/base/sirius-growth/service-blog.yaml new file mode 100644 index 0000000..9508ad7 --- /dev/null +++ b/apps/base/sirius-growth/service-blog.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: sirius-growth-blog + namespace: sirius-growth +spec: + type: ClusterIP + selector: + app: sirius-growth-blog + ports: + - name: http + port: 8092 + targetPort: 8092 + protocol: TCP From c4f7e6378ea61510343ac2a661d723ff6e0b3c49 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 5 Nov 2026 20:50:04 -0500 Subject: [PATCH 24/88] apps(sirius-growth): pin site 2b10d99 (hero plate removed, one-column hero) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index ab34513..3a8af4e 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:d44446c87c5894de29739ee0bd25f40146148bd5 + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:2b10d99387f83d3a7ffc6fd56a950d3c92226dda imagePullPolicy: IfNotPresent ports: - containerPort: 80 From fd555ffb8741400a3dcd5018b1dd22bdc3035d26 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 5 Nov 2026 21:08:57 -0500 Subject: [PATCH 25/88] apps(sirius-growth): pin site 494632d (radish hero plate restored, two-column hero) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 3a8af4e..0195e3b 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:2b10d99387f83d3a7ffc6fd56a950d3c92226dda + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:494632df8f2419ccdf21a5ec83351ccfc3c72f2f imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 017718ba4143e56beea932ea4b79e89a16a811e6 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 6 Nov 2026 16:19:05 -0500 Subject: [PATCH 26/88] apps(sirius-growth): pin site 413d98f (new SG-tree logo icons) --- apps/base/sirius-growth/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment.yaml b/apps/base/sirius-growth/deployment.yaml index 0195e3b..663cc95 100644 --- a/apps/base/sirius-growth/deployment.yaml +++ b/apps/base/sirius-growth/deployment.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/sirius-growth-site:494632df8f2419ccdf21a5ec83351ccfc3c72f2f + image: forgejo.siriusdevops.com/sirius/sirius-growth-site:413d98f6e079fd236c8f17b522be5294bced7875 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 6049a09c6ee070d919ee7df75a4e2d2bf5cd09ef Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 6 Nov 2026 16:36:06 -0500 Subject: [PATCH 27/88] apps(sirius-growth): pin blog 4378680 (new SG-tree mark, favicon-32, apple-touch-icon) --- apps/base/sirius-growth/deployment-blog.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/sirius-growth/deployment-blog.yaml b/apps/base/sirius-growth/deployment-blog.yaml index 65f227c..bc72f8e 100644 --- a/apps/base/sirius-growth/deployment-blog.yaml +++ b/apps/base/sirius-growth/deployment-blog.yaml @@ -24,7 +24,7 @@ spec: # Pinned by immutable tag. The blog is mounted at /journal by the # site nginx, so it has no Service hostname of its own and no # HTTPRoute - the marketing site proxies to this ClusterIP service. - image: forgejo.siriusdevops.com/sirius/sirius-growth-blog:d44446c87c5894de29739ee0bd25f40146148bd5 + image: forgejo.siriusdevops.com/sirius/sirius-growth-blog:4378680888a7d3976106533111003e2cb257a362 imagePullPolicy: IfNotPresent ports: - containerPort: 8092 From f290b3c457fc868c219ae13e6ae5ab13a1cc211f Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 20:14:37 -0500 Subject: [PATCH 28/88] apps(osint): deploy OSINT dashboard stack to k8s at osint.siriusdevops.com New namespace `osint` with the full dashboard stack ported from the Pi docker compose file: TimescaleDB+PostGIS Postgres, NATS JetStream, FastAPI app, ingester, camera-discovery service, TiTiler tile proxy, and the vendored news pipeline (Scrapy scraper + Nous Portal summarizer). - Images built amd64 (the Pi CI only builds arm64) and pushed to the Forgejo registry as :amd64-c48788d4b614; nats/titiler mirrored there too so every pod pulls from one host. - All workloads pinned to siriussec (Gateway/Envoy co-location, local-path PVs). - Postgres is a Deployment+PVC, not CNPG: the alembic chain needs postgis + timescaledb extensions and create_hypertable(). - HTTPRoute osint.siriusdevops.com: /titiler prefix-stripped to TiTiler, everything else to the app (incl. /ws/live). - DB password is Secret osint-db, created out of band (not in git). - Analyst model = meituan/longcat-2.5:free on Nous Portal (free tier). --- apps/base/osint/app-deployment.yaml | 85 +++++++++++++++++++ apps/base/osint/app-service.yaml | 12 +++ apps/base/osint/camera-deployment.yaml | 51 +++++++++++ apps/base/osint/camera-pvc.yaml | 12 +++ apps/base/osint/configmap.yaml | 62 ++++++++++++++ apps/base/osint/httproute.yaml | 34 ++++++++ apps/base/osint/ingester-deployment.yaml | 43 ++++++++++ apps/base/osint/kustomization.yaml | 20 +++++ apps/base/osint/namespace.yaml | 4 + apps/base/osint/nats-deployment.yaml | 53 ++++++++++++ apps/base/osint/nats-service.yaml | 15 ++++ apps/base/osint/news-scraper-deployment.yaml | 44 ++++++++++ .../osint/news-summarizer-deployment.yaml | 44 ++++++++++ apps/base/osint/postgres-deployment.yaml | 82 ++++++++++++++++++ apps/base/osint/postgres-pvc.yaml | 12 +++ apps/base/osint/postgres-service.yaml | 12 +++ apps/base/osint/titiler-deployment.yaml | 51 +++++++++++ apps/base/osint/titiler-service.yaml | 12 +++ apps/home/kustomization.yaml | 1 + 19 files changed, 649 insertions(+) create mode 100644 apps/base/osint/app-deployment.yaml create mode 100644 apps/base/osint/app-service.yaml create mode 100644 apps/base/osint/camera-deployment.yaml create mode 100644 apps/base/osint/camera-pvc.yaml create mode 100644 apps/base/osint/configmap.yaml create mode 100644 apps/base/osint/httproute.yaml create mode 100644 apps/base/osint/ingester-deployment.yaml create mode 100644 apps/base/osint/kustomization.yaml create mode 100644 apps/base/osint/namespace.yaml create mode 100644 apps/base/osint/nats-deployment.yaml create mode 100644 apps/base/osint/nats-service.yaml create mode 100644 apps/base/osint/news-scraper-deployment.yaml create mode 100644 apps/base/osint/news-summarizer-deployment.yaml create mode 100644 apps/base/osint/postgres-deployment.yaml create mode 100644 apps/base/osint/postgres-pvc.yaml create mode 100644 apps/base/osint/postgres-service.yaml create mode 100644 apps/base/osint/titiler-deployment.yaml create mode 100644 apps/base/osint/titiler-service.yaml diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml new file mode 100644 index 0000000..5378408 --- /dev/null +++ b/apps/base/osint/app-deployment.yaml @@ -0,0 +1,85 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-app + namespace: osint + labels: + app: osint-app +spec: + replicas: 1 + selector: + matchLabels: + app: osint-app + template: + metadata: + labels: + app: osint-app + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + initContainers: + # Wait for Postgres before alembic runs (the entrypoint migrates). + - name: wait-for-db + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + command: + - python + - -c + - | + import os, socket, sys, time + host, port = os.environ.get("DB_HOST", "osint-db"), int(os.environ.get("DB_PORT", "5432")) + deadline = time.time() + 300 + while time.time() < deadline: + try: + with socket.create_connection((host, port), timeout=3): + print("postgres is reachable"); sys.exit(0) + except OSError: + time.sleep(3) + sys.exit("postgres did not become reachable in 300s") + containers: + - name: app + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8000 + name: http + envFrom: + - configMapRef: + name: osint-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + readinessProbe: + httpGet: + path: /api/health + port: 8000 + initialDelaySeconds: 10 + periodSeconds: 15 + failureThreshold: 6 + livenessProbe: + httpGet: + path: /api/health + port: 8000 + initialDelaySeconds: 90 + periodSeconds: 30 + failureThreshold: 5 + volumeMounts: + - name: snapshots + mountPath: /data/snapshots + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + volumes: + - name: snapshots + persistentVolumeClaim: + claimName: osint-camera-snapshots diff --git a/apps/base/osint/app-service.yaml b/apps/base/osint/app-service.yaml new file mode 100644 index 0000000..a0f9f4d --- /dev/null +++ b/apps/base/osint/app-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: osint-app + namespace: osint +spec: + selector: + app: osint-app + ports: + - name: http + port: 8000 + targetPort: 8000 diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml new file mode 100644 index 0000000..a5dc6ad --- /dev/null +++ b/apps/base/osint/camera-deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-camera-service + namespace: osint + labels: + app: osint-camera-service +spec: + replicas: 1 + selector: + matchLabels: + app: osint-camera-service + template: + metadata: + labels: + app: osint-camera-service + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: camera-service + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + command: ["python", "app/run_camera_service.py"] + envFrom: + - configMapRef: + name: osint-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + volumeMounts: + - name: snapshots + mountPath: /data/snapshots + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 512Mi + volumes: + # Shared with osint-app (same node, RWO): the app serves cached snapshots. + - name: snapshots + persistentVolumeClaim: + claimName: osint-camera-snapshots diff --git a/apps/base/osint/camera-pvc.yaml b/apps/base/osint/camera-pvc.yaml new file mode 100644 index 0000000..55c2e14 --- /dev/null +++ b/apps/base/osint/camera-pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: osint-camera-snapshots + namespace: osint +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 3Gi diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml new file mode 100644 index 0000000..a30d134 --- /dev/null +++ b/apps/base/osint/configmap.yaml @@ -0,0 +1,62 @@ +# Shared, non-secret runtime configuration for every OSINT workload. +# Secrets (Postgres password, Nous API key, FIRMS/AIS keys) are NOT here: +# * Postgres password -> Secret `osint-db` (created out of band, never in git) +# * API keys -> dashboard Keys page, stored in the `api_keys` table +apiVersion: v1 +kind: ConfigMap +metadata: + name: osint-env + namespace: osint +data: + DB_HOST: osint-db + DB_PORT: "5432" + DB_NAME: osint_data + DB_USER: osint + NATS_URL: nats://osint-nats:4222 + + # SAR tile proxy, exposed same-origin under /titiler by the HTTPRoute. + TITILER_INTERNAL_URL: http://osint-titiler:8000 + TITILER_PUBLIC_BASE: /titiler + + TZ: America/New_York + OSINT_USER_AGENT: "osint-dashboard/1.0 (self-hosted; lancewalters94@gmail.com)" + + # ── ingester ──────────────────────────────────────────────────────────── + INGEST_INTERVAL: "300" + INGEST_EARTHQUAKES: "1" + INGEST_FIRES: "1" + FIRMS_DATASETS: "VIIRS_NOAA20_NRT,VIIRS_NOAA21_NRT" + FIRMS_BBOX: "-180,-60,180,75" + FIRMS_INTERVAL: "900" + VESSELAPI_BBOX: "25.5,55.4,27.3,57.2" + VESSELAPI_INTERVAL: "17280" + VESSELAPI_MAX_CALLS_PER_DAY: "5" + AISSTREAM_IN_APP: "1" + AISSTREAM_IN_INGEST: "0" + VESSELAPI_IN_APP: "0" + VESSELAPI_IN_INGEST: "1" + + # ── camera discovery service ──────────────────────────────────────────── + CAMERA_SOURCE_URLS: "" + CAMERA_SCRAPE_INTERVAL: "3600" + CAMERA_REQUEST_DELAY: "2.0" + CAMERA_MAX_PER_SOURCE: "20000" + NOMINATIM_URL: https://nominatim.openstreetmap.org + NOMINATIM_MIN_INTERVAL: "1.1" + SNAPSHOT_CACHE_DIR: /data/snapshots + SNAPSHOT_TTL_SECONDS: "300" + + # ── news scraper ──────────────────────────────────────────────────────── + LOG_LEVEL: INFO + NEWS_SCRAPE_INTERVAL_S: "10" + NEWS_SCRAPE_RUN_ON_START: "1" + + # ── news summarizer (analyst) — Nous Portal, free tier model ──────────── + NOUS_BASE_URL: https://inference-api.nousresearch.com/v1 + SUMMARY_MODEL: meituan/longcat-2.5:free + BATCH_SIZE: "50" + NEWS_SUMMARIZE_INTERVAL_S: "900" + NEWS_SUMMARIZE_RUN_ON_START: "1" + NEWS_RECAP_HOUR: "23" + NEWS_RECAP_MINUTE: "0" + INCLUDE_FUTURES: "0" diff --git a/apps/base/osint/httproute.yaml b/apps/base/osint/httproute.yaml new file mode 100644 index 0000000..dc1534b --- /dev/null +++ b/apps/base/osint/httproute.yaml @@ -0,0 +1,34 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: osint + namespace: osint +spec: + parentRefs: + - name: public + namespace: gateway-system + hostnames: + - osint.siriusdevops.com + rules: + # Same-origin SAR tile proxy: /titiler/... -> titiler /... (prefix stripped, + # matching the old nginx vhost's `proxy_pass ...:8001/`). + - matches: + - path: + type: PathPrefix + value: /titiler + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + backendRefs: + - name: osint-titiler + port: 8000 + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: osint-app + port: 8000 diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml new file mode 100644 index 0000000..0af6aab --- /dev/null +++ b/apps/base/osint/ingester-deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-ingester + namespace: osint + labels: + app: osint-ingester +spec: + replicas: 1 + selector: + matchLabels: + app: osint-ingester + template: + metadata: + labels: + app: osint-ingester + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: ingester + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + command: ["python", "app/run_ingester.py"] + envFrom: + - configMapRef: + name: osint-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 512Mi diff --git a/apps/base/osint/kustomization.yaml b/apps/base/osint/kustomization.yaml new file mode 100644 index 0000000..af3ccdf --- /dev/null +++ b/apps/base/osint/kustomization.yaml @@ -0,0 +1,20 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + - configmap.yaml + - postgres-pvc.yaml + - postgres-deployment.yaml + - postgres-service.yaml + - nats-deployment.yaml + - nats-service.yaml + - app-deployment.yaml + - app-service.yaml + - ingester-deployment.yaml + - camera-pvc.yaml + - camera-deployment.yaml + - titiler-deployment.yaml + - titiler-service.yaml + - news-scraper-deployment.yaml + - news-summarizer-deployment.yaml + - httproute.yaml diff --git a/apps/base/osint/namespace.yaml b/apps/base/osint/namespace.yaml new file mode 100644 index 0000000..06e4f8f --- /dev/null +++ b/apps/base/osint/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: osint diff --git a/apps/base/osint/nats-deployment.yaml b/apps/base/osint/nats-deployment.yaml new file mode 100644 index 0000000..a17761b --- /dev/null +++ b/apps/base/osint/nats-deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-nats + namespace: osint + labels: + app: osint-nats +spec: + replicas: 1 + selector: + matchLabels: + app: osint-nats + template: + metadata: + labels: + app: osint-nats + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: nats + image: forgejo.siriusdevops.com/sirius/nats:2.10 + imagePullPolicy: IfNotPresent + args: ["-js", "-sd", "/data"] + ports: + - containerPort: 4222 + name: client + - containerPort: 8222 + name: monitor + volumeMounts: + - name: data + mountPath: /data + readinessProbe: + httpGet: + path: /healthz + port: 8222 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + memory: 256Mi + volumes: + # JetStream is a transient bus here (compose had no volume either): + # events are written to Postgres by the consumer loop. + - name: data + emptyDir: {} diff --git a/apps/base/osint/nats-service.yaml b/apps/base/osint/nats-service.yaml new file mode 100644 index 0000000..028f62a --- /dev/null +++ b/apps/base/osint/nats-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: osint-nats + namespace: osint +spec: + selector: + app: osint-nats + ports: + - name: client + port: 4222 + targetPort: 4222 + - name: monitor + port: 8222 + targetPort: 8222 diff --git a/apps/base/osint/news-scraper-deployment.yaml b/apps/base/osint/news-scraper-deployment.yaml new file mode 100644 index 0000000..f2a5a77 --- /dev/null +++ b/apps/base/osint/news-scraper-deployment.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-news-scraper + namespace: osint + labels: + app: osint-news-scraper +spec: + replicas: 1 + selector: + matchLabels: + app: osint-news-scraper + template: + metadata: + labels: + app: osint-news-scraper + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: news-scraper + image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + # Image ENTRYPOINT is `scrapy`; the loop crawls, sleeps, crawls again. + command: ["python", "run_news_scraper.py"] + envFrom: + - configMapRef: + name: osint-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 768Mi diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml new file mode 100644 index 0000000..cab7b5e --- /dev/null +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-news-summarizer + namespace: osint + labels: + app: osint-news-summarizer +spec: + replicas: 1 + selector: + matchLabels: + app: osint-news-summarizer + template: + metadata: + labels: + app: osint-news-summarizer + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: news-summarizer + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + # Loop: batch the last window, call Nous Portal, write summaries. + command: ["python", "run_news_summarizer.py"] + envFrom: + - configMapRef: + name: osint-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 512Mi diff --git a/apps/base/osint/postgres-deployment.yaml b/apps/base/osint/postgres-deployment.yaml new file mode 100644 index 0000000..6ebd382 --- /dev/null +++ b/apps/base/osint/postgres-deployment.yaml @@ -0,0 +1,82 @@ +# TimescaleDB + PostGIS, single instance on local-path. +# NOT CloudNativePG: the app's alembic chain requires CREATE EXTENSION +# postgis AND timescaledb plus create_hypertable()/continuous aggregates, and +# this image (Dockerfile.pg, built amd64) is the exact Postgres the Pi stack +# ran. A CNPG cluster would need a custom CNPG-conformant Timescale image. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-db + namespace: osint + labels: + app: osint-db +spec: + replicas: 1 + # ReadWriteOnce PVC: old and new pod cannot both mount it. + strategy: + type: Recreate + selector: + matchLabels: + app: osint-db + template: + metadata: + labels: + app: osint-db + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: postgres + image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614 + imagePullPolicy: IfNotPresent + args: + - -c + - shared_preload_libraries=timescaledb + - -c + - shared_buffers=1GB + - -c + - max_connections=100 + ports: + - containerPort: 5432 + name: postgres + env: + - name: POSTGRES_USER + value: osint + - name: POSTGRES_DB + value: osint_data + - name: PGDATA + value: /var/lib/postgresql/data/pgdata + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + readinessProbe: + exec: + command: ["pg_isready", "-U", "osint", "-d", "osint_data", "-h", "127.0.0.1"] + initialDelaySeconds: 10 + periodSeconds: 10 + failureThreshold: 6 + livenessProbe: + exec: + command: ["pg_isready", "-U", "osint", "-d", "osint_data", "-h", "127.0.0.1"] + initialDelaySeconds: 60 + periodSeconds: 30 + failureThreshold: 6 + volumeMounts: + - name: pgdata + mountPath: /var/lib/postgresql/data + resources: + requests: + cpu: 200m + memory: 512Mi + limits: + memory: 2Gi + volumes: + - name: pgdata + persistentVolumeClaim: + claimName: osint-pgdata diff --git a/apps/base/osint/postgres-pvc.yaml b/apps/base/osint/postgres-pvc.yaml new file mode 100644 index 0000000..5ebbd76 --- /dev/null +++ b/apps/base/osint/postgres-pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: osint-pgdata + namespace: osint +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 15Gi diff --git a/apps/base/osint/postgres-service.yaml b/apps/base/osint/postgres-service.yaml new file mode 100644 index 0000000..d8bbff2 --- /dev/null +++ b/apps/base/osint/postgres-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: osint-db + namespace: osint +spec: + selector: + app: osint-db + ports: + - name: postgres + port: 5432 + targetPort: 5432 diff --git a/apps/base/osint/titiler-deployment.yaml b/apps/base/osint/titiler-deployment.yaml new file mode 100644 index 0000000..a023e07 --- /dev/null +++ b/apps/base/osint/titiler-deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-titiler + namespace: osint + labels: + app: osint-titiler +spec: + replicas: 1 + selector: + matchLabels: + app: osint-titiler + template: + metadata: + labels: + app: osint-titiler + spec: + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: titiler + image: forgejo.siriusdevops.com/sirius/titiler:0.26.0 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8000 + name: http + env: + - name: PORT + value: "8000" + - name: WORKERS_PER_CORE + value: "1" + - name: WEB_CONCURRENCY + value: "1" + - name: GDAL_CACHEMAX + value: "128" + readinessProbe: + httpGet: + path: /healthz + port: 8000 + initialDelaySeconds: 5 + periodSeconds: 15 + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 512Mi diff --git a/apps/base/osint/titiler-service.yaml b/apps/base/osint/titiler-service.yaml new file mode 100644 index 0000000..f8818d0 --- /dev/null +++ b/apps/base/osint/titiler-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: osint-titiler + namespace: osint +spec: + selector: + app: osint-titiler + ports: + - name: http + port: 8000 + targetPort: 8000 diff --git a/apps/home/kustomization.yaml b/apps/home/kustomization.yaml index 88303d0..1a08fad 100644 --- a/apps/home/kustomization.yaml +++ b/apps/home/kustomization.yaml @@ -5,3 +5,4 @@ resources: - ../base/siriusdevops - ../base/piedmont - ../base/sirius-growth + - ../base/osint From cb86b6972f6c8f468522eda0681e379badfe9178 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 20:20:09 -0500 Subject: [PATCH 29/88] apps(osint): fix Postgres image base (bookworm) + nats monitoring port The cluster PG image built FROM postgres:16 resolved to Debian trixie, whose postgresql-16-postgis-3 (3.7.0+pgdg13) cannot load against PG 16.15: 'undefined symbol: heap_datum_check'. CREATE EXTENSION postgis crashed the server and crashlooped osint-app/osint-camera-service. Rebuild pinned to postgres:16-bookworm (+pgdg12), verified CREATE EXTENSION postgis + timescaledb + create_hypertable() by hand before re-tagging. nats: pass -m 8222 so the monitoring/healthz endpoint the readiness probe hits actually listens. Also documents the stack + build/push/secret steps in apps/base/osint/README.md. --- apps/base/osint/README.md | 75 ++++++++++++++++++++++++ apps/base/osint/nats-deployment.yaml | 2 +- apps/base/osint/pg-image/Dockerfile | 22 +++++++ apps/base/osint/postgres-deployment.yaml | 2 +- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 apps/base/osint/README.md create mode 100644 apps/base/osint/pg-image/Dockerfile diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md new file mode 100644 index 0000000..94c8691 --- /dev/null +++ b/apps/base/osint/README.md @@ -0,0 +1,75 @@ +# OSINT Dashboard stack (namespace `osint`) + +Ported from the Pi docker-compose stack in `sirius/osint-dashboard` so the +dashboard is served from the cluster at **https://osint.siriusdevops.com** +instead of a host Docker container on the Pi. + +## Workloads + +| Deployment | Image | Purpose | +|---|---|---| +| `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | +| `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | +| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-c48788d4b614` | FastAPI + static HUD; runs `alembic upgrade heads` on start | +| `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | +| `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | +| `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | +| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-c48788d4b614` | Scrapy news scraper loop | +| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-c48788d4b614` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | + +Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy +co-location + local-path PVs). + +## Images + +The upstream CI (`.forgejo/workflows/build.yml` in `sirius/osint-dashboard`) +builds **arm64** for the Pi via `runs-on: docker`. The cluster is amd64, so the +images above were built on an amd64 host and pushed to the Forgejo registry +over a `kubectl -n forgejo port-forward svc/forgejo 3000:3000` (Cloudflare +rejects layer uploads ≳100 MB on the public hostname). + +```bash +cd ~/osint-dashboard +SHA=$(git rev-parse --short=12 HEAD) +docker build -f Dockerfile -t 127.0.0.1:3000/sirius/osint-dashboard:$TAG . +docker build -f news/scraper/Dockerfile -t 127.0.0.1:3000/sirius/osint-news-scraper:$TAG news/scraper +docker build -f news/summerizer/Dockerfile -t 127.0.0.1:3000/sirius/osint-news-summarizer:$TAG news/summerizer +docker build -f pg-image/Dockerfile -t 127.0.0.1:3000/sirius/osint-dashboard-pg:$TAG-r2 . +``` + +`pg-image/Dockerfile` is the cluster copy of `Dockerfile.pg`. **It pins +`postgres:16-bookworm`**: the upstream file's bare `postgres:16` now resolves to +Debian trixie, whose `postgresql-16-postgis-3` (3.7.0+pgdg13) fails to load +against PG 16.15 with `undefined symbol: heap_datum_check` — `CREATE EXTENSION +postgis` crashes the server. On bookworm (`+pgdg12`) PostGIS 3.7 loads and +`create_hypertable()` works. Port the one-line base-image pin upstream when the +Pi stack is next rebuilt. + +## Secrets (never in git) + +```bash +kubectl -n osint create secret generic osint-db --from-literal=password='' +``` +`osint-db/password` is used for `POSTGRES_PASSWORD` and every workload's +`DB_PASSWORD`. Regenerating it requires the Postgres role password to be changed +too (`ALTER ROLE osint PASSWORD …`), not just the Secret. + +API keys (Nous Portal `NOUS_API_KEY`, FIRMS, AISStream, VesselAPI) are **not** +Kubernetes Secrets: they live in the dashboard's `api_keys` table and are set +from the Keys page in the UI (`GET/PUT /api/keys`). The summarizer reads +`NOUS_API_KEY` from the env first, then from that table. + +## Analyst model + +`SUMMARY_MODEL=meituan/longcat-2.5:free` (free tier on the Nous Portal, +1M context, verified to honour `response_format: json_object`). It is set in +`configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect +when the env var is empty, because `resolve_model()` prefers the env. + +## Ingress + +Cloudflare tunnel `sirius home` already carries `osint.siriusdevops.com` → +`http://10.10.0.2:8080`. DNS is a proxied CNAME to +`6d0702eb-99cc-4062-b57d-e70e2f1a7895.cfargotunnel.com`. HTTPRoute rule order: +`/titiler` (prefix stripped) → `osint-titiler:8000`, then `/` → `osint-app:8000` +(WebSocket `/ws/live` included). diff --git a/apps/base/osint/nats-deployment.yaml b/apps/base/osint/nats-deployment.yaml index a17761b..772b076 100644 --- a/apps/base/osint/nats-deployment.yaml +++ b/apps/base/osint/nats-deployment.yaml @@ -25,7 +25,7 @@ spec: - name: nats image: forgejo.siriusdevops.com/sirius/nats:2.10 imagePullPolicy: IfNotPresent - args: ["-js", "-sd", "/data"] + args: ["-js", "-m", "8222", "-sd", "/data"] ports: - containerPort: 4222 name: client diff --git a/apps/base/osint/pg-image/Dockerfile b/apps/base/osint/pg-image/Dockerfile new file mode 100644 index 0000000..faa014e --- /dev/null +++ b/apps/base/osint/pg-image/Dockerfile @@ -0,0 +1,22 @@ +# Cluster build of the OSINT Postgres image (amd64). +# +# Identical to `Dockerfile.pg` in sirius/osint-dashboard EXCEPT the base image +# is pinned to bookworm. The upstream `FROM postgres:16` now resolves to Debian +# trixie, where postgresql-16-postgis-3 (3.7.0+pgdg13) fails to load against +# PostgreSQL 16.15: +# could not load library "/usr/lib/postgresql/16/lib/postgis-3.so": +# undefined symbol: heap_datum_check +# On bookworm (+pgdg12) both extensions load and create_hypertable() works. +FROM postgres:16-bookworm + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates curl gnupg lsb-release && \ + curl -fsSL https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash && \ + apt-get update && apt-get install -y --no-install-recommends \ + postgresql-16-postgis-3 timescaledb-2-postgresql-16 && \ + mkdir -p /etc/postgresql/16/main/conf.d && \ + echo "shared_preload_libraries = 'timescaledb'" > /etc/postgresql/16/main/conf.d/timescaledb.conf && \ + rm -rf /var/lib/apt/lists/* + +# The official postgres entrypoint remains the CMD and handles +# POSTGRES_USER / POSTGRES_DB / POSTGRES_PASSWORD and pg_hba setup. diff --git a/apps/base/osint/postgres-deployment.yaml b/apps/base/osint/postgres-deployment.yaml index 6ebd382..936873b 100644 --- a/apps/base/osint/postgres-deployment.yaml +++ b/apps/base/osint/postgres-deployment.yaml @@ -31,7 +31,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: postgres - image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2 imagePullPolicy: IfNotPresent args: - -c From 4ac1cd42d1c111a474cefe0ebae03c45ae980ddf Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 20:33:47 -0500 Subject: [PATCH 30/88] apps(osint): BATCH_SIZE=4 for the Nous free-tier summarizer Map phase has a hard 60 s httpx timeout and meituan/longcat-2.5:free needs ~30 s for 8 articles: batch 1 of the first real run returned 200 in 30 s, batch 2 hit the 60 s ceiling and contributed nothing. 4 keeps every batch inside the timeout. --- apps/base/osint/configmap.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index a30d134..d63ff0e 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -54,7 +54,11 @@ data: # ── news summarizer (analyst) — Nous Portal, free tier model ──────────── NOUS_BASE_URL: https://inference-api.nousresearch.com/v1 SUMMARY_MODEL: meituan/longcat-2.5:free - BATCH_SIZE: "50" + # 4, not the upstream default 50: the map phase runs with a hard 60 s httpx + # timeout (news/summerizer/nous_client.py, json_mode=False), and this free + # model needs ~30 s for 8 articles, so bigger batches time out and silently + # contribute nothing to the reduce phase. + BATCH_SIZE: "4" NEWS_SUMMARIZE_INTERVAL_S: "900" NEWS_SUMMARIZE_RUN_ON_START: "1" NEWS_RECAP_HOUR: "23" From 426fc24d66a36db2a21af955fd78bc3436362604 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:06:43 -0500 Subject: [PATCH 31/88] apps(osint): pin the auth build and wire the single-admin Secret MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit osint-dashboard master d8113b37b8ac adds app/auth.py: deny-by-default on /api/* with a public read allowlist, so visitors get the map + news and only the admin gets keys/settings/mutations. Pin the amd64 image (:amd64-d8113b37b8ac) on app, camera-service and ingester, and feed ADMIN_USER / ADMIN_PASSWORD_HASH / ADMIN_SESSION_SECRET from Secret osint-admin. The refs are optional: true on purpose — a missing Secret must not stop the pod; the app then fails closed (admin routes 403) while the public HUD serves. --- apps/base/osint/app-deployment.yaml | 26 ++++++++++++++++++++++-- apps/base/osint/camera-deployment.yaml | 2 +- apps/base/osint/ingester-deployment.yaml | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index 5378408..6761ef5 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac imagePullPolicy: IfNotPresent ports: - containerPort: 8000 @@ -56,6 +56,28 @@ spec: secretKeyRef: name: osint-db key: password + # Single-admin auth (app/auth.py). optional: true on purpose — a + # missing Secret must not block startup; the app then fails closed + # (admin routes 403 "admin auth not configured") while the public + # read-only HUD still serves. + - name: ADMIN_USER + valueFrom: + secretKeyRef: + name: osint-admin + key: ADMIN_USER + optional: true + - name: ADMIN_PASSWORD_HASH + valueFrom: + secretKeyRef: + name: osint-admin + key: ADMIN_PASSWORD_HASH + optional: true + - name: ADMIN_SESSION_SECRET + valueFrom: + secretKeyRef: + name: osint-admin + key: ADMIN_SESSION_SECRET + optional: true readinessProbe: httpGet: path: /api/health diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml index a5dc6ad..a2ee69d 100644 --- a/apps/base/osint/camera-deployment.yaml +++ b/apps/base/osint/camera-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: camera-service - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac imagePullPolicy: IfNotPresent command: ["python", "app/run_camera_service.py"] envFrom: diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 0af6aab..5f0ddc5 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: From 5b9d17923974638c25462d54c772b3fbfff28b4c Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:09:38 -0500 Subject: [PATCH 32/88] apps(osint): correct the auth image tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first pin (:amd64-d8113b37b8ac) was built from a stale working tree — the local checkout sits on fix/dashboard-geofence-vessels-sentinel-news, not origin/master, so the image carried no app/auth.py and the deployed HUD still served /api/keys open with /login 404. Rebuilt from a detached worktree at d8113b37b8ac (:amd64-d8113b37b8ac-r1, verified /app/app/auth.py exists in the image) and repin the three consumers. --- apps/base/osint/app-deployment.yaml | 4 ++-- apps/base/osint/camera-deployment.yaml | 2 +- apps/base/osint/ingester-deployment.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index 6761ef5..e95b0e1 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 imagePullPolicy: IfNotPresent ports: - containerPort: 8000 diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml index a2ee69d..8a2ed0a 100644 --- a/apps/base/osint/camera-deployment.yaml +++ b/apps/base/osint/camera-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: camera-service - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 imagePullPolicy: IfNotPresent command: ["python", "app/run_camera_service.py"] envFrom: diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 5f0ddc5..40c1174 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: From 28f09d58099ff3411232030de27ffac14b47ebae Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:12:16 -0500 Subject: [PATCH 33/88] docs(osint): admin login, osint-admin Secret, and the known Secure-cookie gap --- apps/base/osint/README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index 94c8691..3d47d87 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -10,7 +10,7 @@ instead of a host Docker container on the Pi. |---|---|---| | `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | | `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | -| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-c48788d4b614` | FastAPI + static HUD; runs `alembic upgrade heads` on start | +| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-d8113b37b8ac-r1` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | | `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | @@ -57,7 +57,36 @@ too (`ALTER ROLE osint PASSWORD …`), not just the Secret. API keys (Nous Portal `NOUS_API_KEY`, FIRMS, AISStream, VesselAPI) are **not** Kubernetes Secrets: they live in the dashboard's `api_keys` table and are set from the Keys page in the UI (`GET/PUT /api/keys`). The summarizer reads -`NOUS_API_KEY` from the env first, then from that table. +`NOUS_API_KEY` from the env first, then from that table. Since the auth change +the Keys page is **admin-only**, so set them while signed in (`/login`). + +### Admin login (`osint-admin`) + +```bash +# password -> pbkdf2 hash (from a checkout of sirius/osint-dashboard) +python app/auth.py hash '' +python -c 'import secrets; print(secrets.token_urlsafe(48))' # session secret + +kubectl -n osint create secret generic osint-admin \ + --from-literal=ADMIN_USER=lance \ + --from-literal=ADMIN_PASSWORD_HASH='pbkdf2_sha256$…' \ + --from-literal=ADMIN_SESSION_SECRET='…' +kubectl -n osint rollout restart deploy/osint-app # env is fixed at container start +``` + +`ADMIN_USER=lance`; the current password lives in +`~/.hermes/secrets/osint_admin_password` (0600, Legion) — never in git. The +three refs in `app-deployment.yaml` are `optional: true` on purpose: a missing +Secret must not block startup, and the app then **fails closed** (admin routes +`403 {"detail":"admin auth not configured"}`) while the public HUD keeps +serving. + +Known gap: the session cookie is `HttpOnly` + `SameSite=Lax` but **not +`Secure`**, because the tunnel origins at plain HTTP and Cilium Envoy rewrites +`X-Forwarded-Proto` to `http`, so `app/auth.py::_is_https()` never sees https +(an explicit request header is discarded too). Fix is carded upstream +(`ADMIN_COOKIE_SECURE`). Until it lands, the zone's **Always Use HTTPS** is what +keeps the cookie off plaintext requests. ## Analyst model From c073ec93085f1adb0fea7f6bed76c5335a4da021 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:13:46 -0500 Subject: [PATCH 34/88] docs(osint): build the merge sha from a detached worktree; note the deleted decoy tag --- apps/base/osint/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index 3d47d87..e98ba63 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -24,13 +24,19 @@ co-location + local-path PVs). The upstream CI (`.forgejo/workflows/build.yml` in `sirius/osint-dashboard`) builds **arm64** for the Pi via `runs-on: docker`. The cluster is amd64, so the -images above were built on an amd64 host and pushed to the Forgejo registry +cluster images were built on an amd64 host and pushed to the Forgejo registry over a `kubectl -n forgejo port-forward svc/forgejo 3000:3000` (Cloudflare -rejects layer uploads ≳100 MB on the public hostname). +rejects layer uploads ≳100 MB on the public hostname). **Build from a detached +worktree at the merge sha, never from the main checkout** — Legion's +`~/osint-dashboard` sits on a feature branch, and a `docker build` there once +produced a `:amd64-` image that carried the right tag and none of the +commit's code (that tag was deleted from the registry; `-r1` is the real build). ```bash -cd ~/osint-dashboard -SHA=$(git rev-parse --short=12 HEAD) +# from the manifests repo root; build the merge sha, not whatever the checkout has +git -C ~/osint-dashboard fetch origin +git -C ~/osint-dashboard worktree add --detach /tmp/osint-build origin/master +cd /tmp/osint-build && SHA=$(git rev-parse --short=12 HEAD) && TAG="amd64-$SHA" docker build -f Dockerfile -t 127.0.0.1:3000/sirius/osint-dashboard:$TAG . docker build -f news/scraper/Dockerfile -t 127.0.0.1:3000/sirius/osint-news-scraper:$TAG news/scraper docker build -f news/summerizer/Dockerfile -t 127.0.0.1:3000/sirius/osint-news-summarizer:$TAG news/summerizer From def2556ee7f10556bded246e3579716c745f8030 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:17:28 -0500 Subject: [PATCH 35/88] apps(osint): ADMIN_COOKIE_SECURE=1 and the 84ea0a17b1af build osint-dashboard master 84ea0a17b1af (PR #51) makes the session cookie Secure when ADMIN_COOKIE_SECURE is truthy, because the tunnel's HTTP origin means Envoy never lets X-Forwarded-Proto through as https. Set the flag in the ConfigMap and pin the three app-image consumers to the rebuilt catalyst. --- apps/base/osint/app-deployment.yaml | 4 ++-- apps/base/osint/camera-deployment.yaml | 2 +- apps/base/osint/configmap.yaml | 6 ++++++ apps/base/osint/ingester-deployment.yaml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index e95b0e1..b2e197a 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af imagePullPolicy: IfNotPresent ports: - containerPort: 8000 diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml index 8a2ed0a..e5a859b 100644 --- a/apps/base/osint/camera-deployment.yaml +++ b/apps/base/osint/camera-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: camera-service - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af imagePullPolicy: IfNotPresent command: ["python", "app/run_camera_service.py"] envFrom: diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index d63ff0e..83bb22f 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -51,6 +51,12 @@ data: NEWS_SCRAPE_INTERVAL_S: "10" NEWS_SCRAPE_RUN_ON_START: "1" + # ── auth (see README, Secret `osint-admin`) ────────────────────────────── + # The Cloudflare tunnel origins at the Cilium Gateway on plain HTTP and Envoy + # normalizes X-Forwarded-Proto to http, so app/auth.py's header inference can + # never see https here: this flag is what puts `Secure` on the session cookie. + ADMIN_COOKIE_SECURE: "1" + # ── news summarizer (analyst) — Nous Portal, free tier model ──────────── NOUS_BASE_URL: https://inference-api.nousresearch.com/v1 SUMMARY_MODEL: meituan/longcat-2.5:free diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 40c1174..b7a7953 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-d8113b37b8ac-r1 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: From 46aec23af738ab1dc9f46b83337c5d9cb785cd18 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:18:48 -0500 Subject: [PATCH 36/88] docs(osint): cookie is Secure via ADMIN_COOKIE_SECURE; pin 84ea0a17b1af --- apps/base/osint/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index e98ba63..f93ce3d 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -10,7 +10,7 @@ instead of a host Docker container on the Pi. |---|---|---| | `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | | `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | -| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-d8113b37b8ac-r1` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | +| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-84ea0a17b1af` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | | `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | @@ -87,12 +87,12 @@ Secret must not block startup, and the app then **fails closed** (admin routes `403 {"detail":"admin auth not configured"}`) while the public HUD keeps serving. -Known gap: the session cookie is `HttpOnly` + `SameSite=Lax` but **not -`Secure`**, because the tunnel origins at plain HTTP and Cilium Envoy rewrites -`X-Forwarded-Proto` to `http`, so `app/auth.py::_is_https()` never sees https -(an explicit request header is discarded too). Fix is carded upstream -(`ADMIN_COOKIE_SECURE`). Until it lands, the zone's **Always Use HTTPS** is what -keeps the cookie off plaintext requests. +The session cookie is `HttpOnly` + `SameSite=Lax` + `Secure`. `Secure` comes from +`ADMIN_COOKIE_SECURE=1` (ConfigMap), **not** from header inference: the tunnel +origins at plain HTTP and Cilium Envoy rewrites `X-Forwarded-Proto` to `http`, so +`app/auth.py::_is_https()` never sees https (an explicit request header is +discarded too — verified). Leave the flag unset only if you ever serve this over +plain http locally; browsers will not send a `Secure` cookie there. ## Analyst model From ff1dc24b9334bd0f090146207324821b474dc424 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:43:58 -0500 Subject: [PATCH 37/88] =?UTF-8?q?apps(osint):=2058f71f5b4520=20=E2=80=94?= =?UTF-8?q?=20future-dated=20items=20dropped=20at=20ingest,=20hidden=20in?= =?UTF-8?q?=20/api/news?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #52: the Scrapy pipeline drops items dated >2h ahead (event listings were pinning ORDER BY timestamp DESC), and /api/news excludes rows where timestamp > now() as a second guard. Rebuild app + scraper at the merge sha. --- apps/base/osint/app-deployment.yaml | 4 ++-- apps/base/osint/camera-deployment.yaml | 2 +- apps/base/osint/ingester-deployment.yaml | 2 +- apps/base/osint/news-scraper-deployment.yaml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index b2e197a..91cc7cb 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 imagePullPolicy: IfNotPresent ports: - containerPort: 8000 diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml index e5a859b..04a79ed 100644 --- a/apps/base/osint/camera-deployment.yaml +++ b/apps/base/osint/camera-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: camera-service - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 imagePullPolicy: IfNotPresent command: ["python", "app/run_camera_service.py"] envFrom: diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index b7a7953..6d5e711 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-84ea0a17b1af + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: diff --git a/apps/base/osint/news-scraper-deployment.yaml b/apps/base/osint/news-scraper-deployment.yaml index f2a5a77..c211ee8 100644 --- a/apps/base/osint/news-scraper-deployment.yaml +++ b/apps/base/osint/news-scraper-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: news-scraper - image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-58f71f5b4520 imagePullPolicy: IfNotPresent # Image ENTRYPOINT is `scrapy`; the loop crawls, sleeps, crawls again. command: ["python", "run_news_scraper.py"] From 550bbdc61ddca0b1dc9f9797da44638b785e72d2 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:47:04 -0500 Subject: [PATCH 38/88] docs(osint): news-list hygiene guards and the 58f71f5b4520 pins --- apps/base/osint/README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index f93ce3d..69ec382 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -10,11 +10,11 @@ instead of a host Docker container on the Pi. |---|---|---| | `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | | `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | -| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-84ea0a17b1af` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | +| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-58f71f5b4520` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | | `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | -| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-c48788d4b614` | Scrapy news scraper loop | +| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop | | `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-c48788d4b614` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy @@ -94,6 +94,21 @@ origins at plain HTTP and Cilium Envoy rewrites `X-Forwarded-Proto` to `http`, s discarded too — verified). Leave the flag unset only if you ever serve this over plain http locally; browsers will not send a `Secure` cookie there. +## News list hygiene + +`/api/news` orders by `articles.timestamp DESC`, so anything dated in the future +pins the top of the feed indefinitely. Two guards (PR #52): + +- the Scrapy pipeline drops items dated more than **2 h** ahead + (`FUTURE_TOLERANCE` in `newsScraper/pipelines.py`), counting them under the + `future_dated_dropped` stat and logging one INFO line per crawl; +- `GET /api/news` additionally excludes `timestamp > now()` (keeping + `timestamp IS NULL` rows), so rows already in the table can never resurface + early. + +Items with an unparseable date are still kept — the guard only fires on a date +it can actually parse. + ## Analyst model `SUMMARY_MODEL=meituan/longcat-2.5:free` (free tier on the Nous Portal, From 6d4813e2ece04bc8cf5664e206c294124adbcc0a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:49:49 -0500 Subject: [PATCH 39/88] =?UTF-8?q?apps(osint):=20map-phase=20grading=20?= =?UTF-8?q?=E2=80=94=20summarizer=202c41737d42dd=20+=20score=20thresholds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #53 grades every article 0-100 inside the existing map call (no extra round-trip), passes only blocks >= SUMMARY_MIN_SCORE to the reduce prompt and persists article_scores for threshold tuning. Pin the rebuilt summarizer and set min_score=60 / top_n=12 / fallback_top=3 in the ConfigMap. --- apps/base/osint/configmap.yaml | 7 +++++++ apps/base/osint/news-summarizer-deployment.yaml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index 83bb22f..4a46b4a 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -65,6 +65,13 @@ data: # model needs ~30 s for 8 articles, so bigger batches time out and silently # contribute nothing to the reduce phase. BATCH_SIZE: "4" + # Map-phase grading (PR #53): the map call scores every article 0-100 against + # a rubric and only blocks >= SUMMARY_MIN_SCORE reach the brief. When nothing + # clears the bar the top SUMMARY_FALLBACK_TOP are used so the HUD is not blank + # (set 0 for a genuinely empty "no significant developments" brief). + SUMMARY_MIN_SCORE: "60" + SUMMARY_TOP_N: "12" + SUMMARY_FALLBACK_TOP: "3" NEWS_SUMMARIZE_INTERVAL_S: "900" NEWS_SUMMARIZE_RUN_ON_START: "1" NEWS_RECAP_HOUR: "23" diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml index cab7b5e..ed4fd1a 100644 --- a/apps/base/osint/news-summarizer-deployment.yaml +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: news-summarizer - image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-c48788d4b614 + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-2c41737d42dd imagePullPolicy: IfNotPresent # Loop: batch the last window, call Nous Portal, write summaries. command: ["python", "run_news_summarizer.py"] From 7edb32f6276032caeb4595165dde34d8f70f5104 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 21:58:06 -0500 Subject: [PATCH 40/88] =?UTF-8?q?apps(osint):=20summarizer=20fa745ee3f7ae?= =?UTF-8?q?=20=E2=80=94=20closed=20window=20+=20fallback=20score=20floor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #54: get_recent_news() now ends at NOW() so future-dated event listings are no longer re-graded every interval, and the fallback can only pick blocks with score >= SUMMARY_FALLBACK_MIN_SCORE (40) instead of taking the top N blind. --- apps/base/osint/configmap.yaml | 3 +++ apps/base/osint/news-summarizer-deployment.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index 4a46b4a..29e5b8e 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -72,6 +72,9 @@ data: SUMMARY_MIN_SCORE: "60" SUMMARY_TOP_N: "12" SUMMARY_FALLBACK_TOP: "3" + # Lowest score the fallback may pick when nothing clears SUMMARY_MIN_SCORE; + # below this the brief is the honest "no significant developments" one. + SUMMARY_FALLBACK_MIN_SCORE: "40" NEWS_SUMMARIZE_INTERVAL_S: "900" NEWS_SUMMARIZE_RUN_ON_START: "1" NEWS_RECAP_HOUR: "23" diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml index ed4fd1a..7e39ca1 100644 --- a/apps/base/osint/news-summarizer-deployment.yaml +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: news-summarizer - image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-2c41737d42dd + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fa745ee3f7ae imagePullPolicy: IfNotPresent # Loop: batch the last window, call Nous Portal, write summaries. command: ["python", "run_news_summarizer.py"] From aede328bf008e56c8726b2a64e07c7ddb5c86da9 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 22:08:07 -0500 Subject: [PATCH 41/88] docs(osint): analyst grading rubric, thresholds and article_scores --- apps/base/osint/README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index 69ec382..6a0845f 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -15,7 +15,7 @@ instead of a host Docker container on the Pi. | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | | `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop | -| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-c48788d4b614` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | +| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fa745ee3f7ae` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy co-location + local-path PVs). @@ -116,6 +116,33 @@ it can actually parse. `configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect when the env var is empty, because `resolve_model()` prefers the env. +## Analyst grading (PR #53 + #54) + +The map call scores every article **0-100** against a rubric in the same request +(no extra round-trip): 90+ breaking geopolitical/military/disaster, 70-89 +significant national/international, 40-69 notable regional, 10-39 routine/crime, +0-9 noise (sport, celebrity, market tape, **event-calendar listings**). Only +blocks scoring `>= SUMMARY_MIN_SCORE` (60) reach the reduce prompt, capped at +`SUMMARY_TOP_N` (12). If nothing clears the bar the fallback may only pick blocks +`>= SUMMARY_FALLBACK_MIN_SCORE` (40), and if none clear that the brief is the +honest `No significant developments in this window.` — `SUMMARY_FALLBACK_TOP=0` +disables the fallback entirely. + +`get_recent_news()` uses a closed window `(now - window, now]`: future-dated rows +must never be re-graded every 15 minutes (they are dropped at ingest and hidden +in `/api/news` — see above). + +Every graded article is persisted to `article_scores` (`score`, `category`, +`selected`, `model`, `summary_id`) for threshold tuning, e.g. + +```sql +select width_bucket(score, 0, 100, 10) * 10 as bucket, count(*), avg(selected::int) +from article_scores group by 1 order by 1; +``` + +Known gap (carded): syndicated wire copies are not yet collapsed, so several +`top_n` slots can hold the same story from different stations. + ## Ingress Cloudflare tunnel `sirius home` already carries `osint.siriusdevops.com` → From a9d3a4eb33c380e3301b42ea24d541940a954884 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 22:16:50 -0500 Subject: [PATCH 42/88] =?UTF-8?q?apps(osint):=20summarizer=20d04ddc9afacb?= =?UTF-8?q?=20=E2=80=94=20syndication=20dedupe=20before=20selection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #55 collapses normalised-title duplicates (7 Hearst stations carrying one wire story) to the best-scoring representative before min_score/top_n, stores duplicates with selected=false + duplicate_of, and exposes SUMMARY_DEDUPE / SUMMARY_DEDUPE_SIMILARITY (0.85). --- apps/base/osint/configmap.yaml | 5 +++++ apps/base/osint/news-summarizer-deployment.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index 29e5b8e..bdc0e70 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -75,6 +75,11 @@ data: # Lowest score the fallback may pick when nothing clears SUMMARY_MIN_SCORE; # below this the brief is the honest "no significant developments" one. SUMMARY_FALLBACK_MIN_SCORE: "40" + # Syndication dedupe (PR #55): identical wire copy from sister stations is + # collapsed to one representative before the threshold/cap, so top_n buys + # distinct stories. SUMMARY_DEDUPE=0 disables it. + SUMMARY_DEDUPE: "1" + SUMMARY_DEDUPE_SIMILARITY: "0.85" NEWS_SUMMARIZE_INTERVAL_S: "900" NEWS_SUMMARIZE_RUN_ON_START: "1" NEWS_RECAP_HOUR: "23" diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml index 7e39ca1..edfec15 100644 --- a/apps/base/osint/news-summarizer-deployment.yaml +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: news-summarizer - image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fa745ee3f7ae + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-d04ddc9afacb imagePullPolicy: IfNotPresent # Loop: batch the last window, call Nous Portal, write summaries. command: ["python", "run_news_summarizer.py"] From 274b3aaaedf57d6426fdc0aa38e6461fe7cc0b8a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 13 Nov 2026 22:20:58 -0500 Subject: [PATCH 43/88] docs(osint): syndication dedupe knobs and the d04ddc9afacb pin --- apps/base/osint/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index 6a0845f..fc41c92 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -15,7 +15,7 @@ instead of a host Docker container on the Pi. | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | | `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop | -| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fa745ee3f7ae` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | +| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-d04ddc9afacb` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy co-location + local-path PVs). @@ -140,8 +140,13 @@ select width_bucket(score, 0, 100, 10) * 10 as bucket, count(*), avg(selected::i from article_scores group by 1 order by 1; ``` -Known gap (carded): syndicated wire copies are not yet collapsed, so several -`top_n` slots can hold the same story from different stations. +Before the threshold/cap, `dedupe_blocks()` collapses **syndicated wire copies** +(six Hearst stations carrying one AP story) onto the best-scoring representative, +comparing normalised titles — lowercase, source suffix (` - KCCI`, ` | CNN`) +stripped when the tail is short and digit-free — with word-set Jaccard / +sequence similarity `>= SUMMARY_DEDUPE_SIMILARITY` (0.85). Duplicates are still +graded and persisted, with `selected=false` and `duplicate_of` pointing at the +survivor. `SUMMARY_DEDUPE=0` disables the collapse. ## Ingress From d9bde195cdc25972ff56b23aced933930b883f73 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 16 Nov 2026 20:41:20 -0500 Subject: [PATCH 44/88] apps(forgejo): clear stale dind pid on start so runner restarts self-heal The dind container mounts the dind-run emptyDir at /var/run. A reboot restarts the container inside the same pod, so that emptyDir keeps the dead daemon's docker.pid; dockerd then aborts with "process with PID N is still running" and the runner sits in CrashLoopBackOff until someone deletes the pod. Removing the stale pid and socket before starting dockerd makes both the amd64 and arm64 runners recover on their own. --- apps/base/forgejo/runner-amd64.yaml | 7 +++++++ apps/base/forgejo/runner-arm64.yaml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/apps/base/forgejo/runner-amd64.yaml b/apps/base/forgejo/runner-amd64.yaml index 44e9008..cdadc0d 100644 --- a/apps/base/forgejo/runner-amd64.yaml +++ b/apps/base/forgejo/runner-amd64.yaml @@ -76,6 +76,13 @@ spec: - sh - -c - | + # A reboot restarts this container inside the same pod, so the + # dind-run emptyDir keeps the previous daemon's pid file. dockerd + # then refuses to start ("process with PID N is still running") + # and the runner crashloops until the pod is deleted by hand. + # Clear the stale runtime state first so a restart is + # self-healing. + rm -f /var/run/docker.pid /var/run/docker.sock dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 & pid=$! i=0 diff --git a/apps/base/forgejo/runner-arm64.yaml b/apps/base/forgejo/runner-arm64.yaml index 74d2e5a..bb66a61 100644 --- a/apps/base/forgejo/runner-arm64.yaml +++ b/apps/base/forgejo/runner-arm64.yaml @@ -46,6 +46,13 @@ spec: - sh - -c - | + # A reboot restarts this container inside the same pod, so the + # dind-run emptyDir keeps the previous daemon's pid file. dockerd + # then refuses to start ("process with PID N is still running") + # and the runner crashloops until the pod is deleted by hand. + # Clear the stale runtime state first so a restart is + # self-healing. + rm -f /var/run/docker.pid /var/run/docker.sock # --insecure-registry: the Pi registry is plain HTTP on the WG # hub IP. Docker only treats 127.0.0.0/8 as insecure by default, # so without this `docker push 10.10.0.1:5000/...` from a job From 318e633419272ff07bf5567e210782f8094a5508 Mon Sep 17 00:00:00 2001 From: tui-design Date: Tue, 17 Nov 2026 15:04:00 -0500 Subject: [PATCH 45/88] ci(forgejo): let the amd64 dind daemon push to the in-cluster registry Forgejo's container registry now lives in the cluster and is reachable only as the plain-HTTP ClusterIP forgejo.forgejo.svc.cluster.local:3000. Docker treats only 127.0.0.0/8 as insecure, so any workflow logging in to or pushing to that host would fail with "server gave HTTP response to HTTPS client". Adds --insecure-registry for that host to the amd64 dind daemon, which is the runner the osint-dashboard build now targets (amd64 matches the cluster, so images are usable on the nodes). --- apps/base/forgejo/runner-amd64.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/base/forgejo/runner-amd64.yaml b/apps/base/forgejo/runner-amd64.yaml index cdadc0d..7fa6dba 100644 --- a/apps/base/forgejo/runner-amd64.yaml +++ b/apps/base/forgejo/runner-amd64.yaml @@ -83,7 +83,16 @@ spec: # Clear the stale runtime state first so a restart is # self-healing. rm -f /var/run/docker.pid /var/run/docker.sock - dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 & + # Forgejo's container registry is reached in-cluster as a plain + # HTTP ClusterIP (forgejo.forgejo.svc.cluster.local:3000). + # Docker only treats 127.0.0.0/8 as insecure by default, so + # without this a workflow that logs in to or pushes to that host + # dies with "server gave HTTP response to HTTPS client". + # The public hostname stays HTTPS via Cloudflare, which 413s + # layer uploads >~100MB, so in-cluster pushes are the reliable + # path for large images. + dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \ + --insecure-registry=forgejo.forgejo.svc.cluster.local:3000 & pid=$! i=0 while [ "$i" -lt 30 ]; do From a385a8a360e82dfaf83e30245cdb1ae3d644e19a Mon Sep 17 00:00:00 2001 From: tui-design Date: Tue, 17 Nov 2026 15:05:26 -0500 Subject: [PATCH 46/88] ci(forgejo): give amd64 job containers the docker CLI Dispatch of the rewired osint build (run 1363) reached the new login step and died with '/var/run/act/workflow/3: line 9: docker: command not found'. amd64.toml only set docker_host, which injects the socket bind but not a CLI, and the job image is node:20-bullseye (no docker). arm64.toml already solves this by bind-mounting the dind sidecar's own /usr/local/bin/docker and cli-plugins into the job container; do the same here and drop docker_host so the socket is not mounted twice. No --memory cap: this runner also carries the existing amd64 release builds, which were already uncapped. --- apps/base/forgejo/runner-configmap.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/base/forgejo/runner-configmap.yaml b/apps/base/forgejo/runner-configmap.yaml index 5c2f132..fd489fb 100644 --- a/apps/base/forgejo/runner-configmap.yaml +++ b/apps/base/forgejo/runner-configmap.yaml @@ -99,7 +99,18 @@ data: dir: /data/cache container: privileged: true - docker_host: "unix:///var/run/docker.sock" + # No docker_host: it injects the socket bind into the job container, + # which collides with the explicit -v /var/run/docker.sock in options + # ("Duplicate mount point"). The options bind is the deliberate choice. + # + # The job image is node:20-bullseye, which ships no docker CLI, so the + # socket alone is not enough — `docker login`/`build`/`push` die with + # "docker: command not found". The CLI and cli-plugins come from the + # dind sidecar's own filesystem (docker:27-dind ships /usr/local/bin/ + # docker, docker-buildx, docker-compose), same as arm64.toml. + # No --memory cap: this runner also carries the existing amd64 release + # builds, which were already uncapped. + options: -v /usr/local/bin/docker:/usr/bin/docker:ro -v /usr/local/libexec/docker/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock force_pull: true valid_volumes: - "**" From 05864f3c2c1fd66529663c4977b39417a7d3ec6a Mon Sep 17 00:00:00 2001 From: Hermes DevOps Date: Thu, 19 Nov 2026 16:15:29 -0500 Subject: [PATCH 47/88] apps(siriusdevops): serve owner media from the private Garage bucket - site image pinned to :4d03fc814d39... (nginx.conf gains location /media/) - initContainer media-sync pulls s3://siriusdevops-media from 10.10.0.1:3900 over the WireGuard mesh into an emptyDir mounted at /usr/share/nginx/html/media; creds from secret garage-media-s3 - the sync retries 5x then exits 0, so a Garage outage cannot take the site down (headshot falls back to its monogram) - the bucket stays private: no website access, no public hostname --- apps/base/siriusdevops/deployment-site.yaml | 62 ++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 0bb6daa..00b5cd3 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -19,13 +19,70 @@ spec: effect: PreferNoSchedule nodeSelector: kubernetes.io/hostname: siriussec + # Owner media is NOT in the image, and the Garage bucket stays private + # (WireGuard-only: no website access, no public hostname). This + # initContainer pulls s3://siriusdevops-media over the mesh into an + # emptyDir that nginx serves at /media/. Baked assets (site.css, og.png, + # favicon, screenshots) stay baked - scope is owner media only. + # + # It must never take the site down: if Garage is unreachable at boot it + # retries a few times, then exits 0 with a warning and the page serves + # with the monogram fallback instead of the headshot. + initContainers: + - name: media-sync + image: amazon/aws-cli@sha256:7a77ccb39e3272191adbf905c50db8c127db88fd79454911a41a6b1c0e419e9b + imagePullPolicy: IfNotPresent + command: + - /bin/sh + - -c + - | + set -u + for attempt in 1 2 3 4 5; do + if aws s3 sync "s3://siriusdevops-media/" /media/ \ + --endpoint-url http://10.10.0.1:3900 \ + --only-show-errors; then + echo "media sync ok (attempt $attempt): $(ls -R /media | head -20)" + exit 0 + fi + echo "media sync attempt $attempt failed; retrying in 10s" + sleep 10 + done + echo "WARNING: media sync failed after 5 attempts - serving without /media (headshot falls back to monogram)" + exit 0 + env: + # aws-cli v2 sends a CRC32 checksum header on PutObject/HeadObject + # by default and Garage v1.1.0 rejects it as "invalid checksum + # algorithm" - only send checksums when an operation requires one. + - name: AWS_DEFAULT_REGION + value: garage + - name: AWS_EC2_METADATA_DISABLED + value: "true" + - name: AWS_REQUEST_CHECKSUM_CALCULATION + value: when_required + - name: AWS_RESPONSE_CHECKSUM_VALIDATION + value: when_required + envFrom: + - secretRef: + name: garage-media-s3 + volumeMounts: + - name: media + mountPath: /media + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:f0dde2f48c8224fb80d801ecb0d155c93332dc13 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:4d03fc814d39faaf5d8cc64b794aa4bc19f72995 imagePullPolicy: IfNotPresent ports: - containerPort: 80 name: http + volumeMounts: + - name: media + mountPath: /usr/share/nginx/html/media readinessProbe: httpGet: path: / @@ -38,3 +95,6 @@ spec: memory: 64Mi limits: memory: 256Mi + volumes: + - name: media + emptyDir: {} From d82e1b9f2a24b0d0cd13d330f1f045a50480c4c9 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 16:32:58 -0500 Subject: [PATCH 48/88] infrastructure(garage): commit the config, prove WG-only, split keys, back it up, scrape it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 root@10.20.0.1:/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. --- apps/base/siriusdevops/kustomization.yaml | 1 + .../networkpolicy-site-egress.yaml | 70 +++++ infrastructure/garage/README.md | 239 ++++++++++++++++++ infrastructure/garage/backup/garage-backup.sh | 88 +++++++ .../garage/backup/garage-data-backup.service | 17 ++ .../garage/backup/garage-data-backup.timer | 12 + .../garage/backup/garage-meta-backup.service | 15 ++ .../garage/backup/garage-meta-backup.timer | 13 + infrastructure/garage/docker-compose.yml | 53 ++++ infrastructure/garage/garage.toml | 42 +++ .../garage/host/garage-firewall.nft | 41 +++ .../garage/host/garage-firewall.service | 25 ++ .../garage/host/install-garage-firewall.sh | 22 ++ monitoring/controllers/home/garage.yaml | 163 ++++++++++++ .../controllers/home/kustomization.yaml | 1 + 15 files changed, 802 insertions(+) create mode 100644 apps/base/siriusdevops/networkpolicy-site-egress.yaml create mode 100644 infrastructure/garage/README.md create mode 100644 infrastructure/garage/backup/garage-backup.sh create mode 100644 infrastructure/garage/backup/garage-data-backup.service create mode 100644 infrastructure/garage/backup/garage-data-backup.timer create mode 100644 infrastructure/garage/backup/garage-meta-backup.service create mode 100644 infrastructure/garage/backup/garage-meta-backup.timer create mode 100644 infrastructure/garage/docker-compose.yml create mode 100644 infrastructure/garage/garage.toml create mode 100644 infrastructure/garage/host/garage-firewall.nft create mode 100644 infrastructure/garage/host/garage-firewall.service create mode 100644 infrastructure/garage/host/install-garage-firewall.sh create mode 100644 monitoring/controllers/home/garage.yaml diff --git a/apps/base/siriusdevops/kustomization.yaml b/apps/base/siriusdevops/kustomization.yaml index 742b5df..aa601cb 100644 --- a/apps/base/siriusdevops/kustomization.yaml +++ b/apps/base/siriusdevops/kustomization.yaml @@ -7,3 +7,4 @@ 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 new file mode 100644 index 0000000..389e5c8 --- /dev/null +++ b/apps/base/siriusdevops/networkpolicy-site-egress.yaml @@ -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 diff --git a/infrastructure/garage/README.md b/infrastructure/garage/README.md new file mode 100644 index 0000000..90868ce --- /dev/null +++ b/infrastructure/garage/README.md @@ -0,0 +1,239 @@ +# 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 new file mode 100644 index 0000000..ea8688f --- /dev/null +++ b/infrastructure/garage/backup/garage-backup.sh @@ -0,0 +1,88 @@ +#!/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 new file mode 100644 index 0000000..320e316 --- /dev/null +++ b/infrastructure/garage/backup/garage-data-backup.service @@ -0,0 +1,17 @@ +# /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 new file mode 100644 index 0000000..d6b35a4 --- /dev/null +++ b/infrastructure/garage/backup/garage-data-backup.timer @@ -0,0 +1,12 @@ +# /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 new file mode 100644 index 0000000..6ef30a5 --- /dev/null +++ b/infrastructure/garage/backup/garage-meta-backup.service @@ -0,0 +1,15 @@ +# /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 new file mode 100644 index 0000000..c7a43aa --- /dev/null +++ b/infrastructure/garage/backup/garage-meta-backup.timer @@ -0,0 +1,13 @@ +# /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 new file mode 100644 index 0000000..e8cff27 --- /dev/null +++ b/infrastructure/garage/docker-compose.yml @@ -0,0 +1,53 @@ +# 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 new file mode 100644 index 0000000..93f202a --- /dev/null +++ b/infrastructure/garage/garage.toml @@ -0,0 +1,42 @@ +# 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 new file mode 100644 index 0000000..4f8cc61 --- /dev/null +++ b/infrastructure/garage/host/garage-firewall.nft @@ -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 + } +} diff --git a/infrastructure/garage/host/garage-firewall.service b/infrastructure/garage/host/garage-firewall.service new file mode 100644 index 0000000..3f9ce7e --- /dev/null +++ b/infrastructure/garage/host/garage-firewall.service @@ -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 diff --git a/infrastructure/garage/host/install-garage-firewall.sh b/infrastructure/garage/host/install-garage-firewall.sh new file mode 100644 index 0000000..7f41779 --- /dev/null +++ b/infrastructure/garage/host/install-garage-firewall.sh @@ -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 diff --git a/monitoring/controllers/home/garage.yaml b/monitoring/controllers/home/garage.yaml new file mode 100644 index 0000000..fa10181 --- /dev/null +++ b/monitoring/controllers/home/garage.yaml @@ -0,0 +1,163 @@ +# 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 e7c4414..bb12166 100644 --- a/monitoring/controllers/home/kustomization.yaml +++ b/monitoring/controllers/home/kustomization.yaml @@ -7,6 +7,7 @@ resources: - release.yaml - httproute.yaml - gateway-probe.yaml + - garage.yaml - prune-alerts.yaml - dashboards configMapGenerator: From c9ec270c228cbdc0ba520382fa4ff92e090e7461 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 16:33:50 -0500 Subject: [PATCH 49/88] docs(cluster-overview): Garage ports, firewall, keys, backup after the hardening pass --- docs/cluster-overview.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index 9338bc2..f7b7ac4 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -296,16 +296,20 @@ 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`, 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` | +| 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` | -**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. +**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). -**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. +**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. --- @@ -524,7 +528,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`; loopback on `3900-3902` **plus `10.10.0.1:3900`** (S3 is reachable from pods) | +| 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/` | | 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`) | @@ -565,7 +569,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-3902` **and `10.10.0.1:3900`** | +| 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 | | 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 | From b698f23d4f53e6b31770fe36f2389ee0d0481e5f Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 17:01:05 -0500 Subject: [PATCH 50/88] apps(backup): nightly Forgejo data + CNPG dumps to the Linode, and prove a restore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing on this platform backed up Forgejo or the CloudNativePG databases; docs/cluster-overview.md had claimed both must be backed up for months. New CronJob forgejo/cluster-backup (37 2 * * * UTC, Forbid) streams to root@10.10.0.5:/root/cluster-backup over the WireGuard mesh: * forgejo-data PVC mirrored with rsync --link-dest (snapshot per night, hardlinked, readonly PVC mount, transient upload spools excluded, rsync exit 24 tolerated because Forgejo is live while it runs); * pg_dump -Fc from inside each CNPG primary (local socket, no DB password in git) for forgejo/pg and sirius-growth/portal, sha256-verified on both sides before the .part file is renamed. Nothing is staged on siriussec (83% full, DiskPressure hazard); the job has an ephemeral-storage cap of 1Gi to make that structural. Job lives in ns forgejo because a PVC cannot be mounted cross-namespace; the portal dump uses exec-only RBAC declared in apps/base/sirius-growth/backup-exec-rbac.yaml. Only secret is forgejo/cluster-backup-ssh (out of band, not in git): from=-restricted ed25519 key on the Linode, host key pinned. docs/cluster-overview.md: §8.1 coverage + honest gaps, §8.2 restore runbook, live PVC/disk numbers corrected. --- apps/base/forgejo/cluster-backup.yaml | 272 ++++++++++++++++++ apps/base/forgejo/kustomization.yaml | 3 + apps/base/sirius-growth/backup-exec-rbac.yaml | 41 +++ apps/base/sirius-growth/kustomization.yaml | 3 + docs/cluster-overview.md | 93 +++++- 5 files changed, 405 insertions(+), 7 deletions(-) create mode 100644 apps/base/forgejo/cluster-backup.yaml create mode 100644 apps/base/sirius-growth/backup-exec-rbac.yaml diff --git a/apps/base/forgejo/cluster-backup.yaml b/apps/base/forgejo/cluster-backup.yaml new file mode 100644 index 0000000..1e7386c --- /dev/null +++ b/apps/base/forgejo/cluster-backup.yaml @@ -0,0 +1,272 @@ +--- +# Nightly backup of every piece of state on this cluster that is not +# rebuildable from git: Forgejo's data PVC and the CloudNativePG databases. +# +# Why this lives in namespace `forgejo` (and not a `backup` namespace): +# the biggest artifact is the `forgejo-data` PVC, and a Kubernetes volume +# cannot be mounted from another namespace. The pod therefore runs beside the +# data it copies; the portal database is reached over the API (see RBAC). +# +# Design notes (see docs/cluster-overview.md §8.1): +# * Destination is the Linode VPS (`root@10.10.0.5:/root/cluster-backup`), +# reached over the WireGuard mesh — off the T480 AND off the Pi. The same +# host already carries `/root/garage-backup` from the Garage pass. +# * Forgejo data is a *link-dest snapshot mirror*: rsync only ships changed +# blocks but every night leaves a full, restorable hardlinked snapshot. +# Never staged on the T480's root fs (it runs close to DiskPressure) — +# data flows PVC -> rsync -> ssh, no local temp file. +# * Databases are `pg_dump -Fc` streams taken from inside the CNPG primary +# (local socket, `-U postgres`, no password in the manifest and no +# cross-namespace Secret copy) piped straight to the Linode. +# * Credential-free on the DB side is deliberate: nothing in git, nothing to +# rotate. The only secret is the backup SSH key (`cluster-backup-ssh`, +# created out of band, `from=`-restricted on the Linode). +apiVersion: v1 +kind: ServiceAccount +metadata: + name: cluster-backup + namespace: forgejo + labels: + app: cluster-backup +--- +# Dump source in this namespace: find the CNPG primary and run pg_dump in it. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: cluster-backup + namespace: forgejo + labels: + app: cluster-backup +rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list"] + - apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create"] + - apiGroups: ["postgresql.cnpg.io"] + resources: ["clusters"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: cluster-backup + namespace: forgejo + labels: + app: cluster-backup +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: cluster-backup +subjects: + - kind: ServiceAccount + name: cluster-backup + namespace: forgejo +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: cluster-backup-scripts + namespace: forgejo + labels: + app: cluster-backup +data: + backup.sh: | + #!/bin/bash + # Nightly state backup: Forgejo data PVC + every CloudNativePG database. + # + # Layout on the Linode: + # /root/cluster-backup/forgejo-data// hardlinked snapshot + # /root/cluster-backup/forgejo-data/latest -> newest snapshot + # /root/cluster-backup/db/--.dump pg_dump -Fc + # /root/cluster-backup/manifests/.txt sizes + sha256 + # + # Everything is streamed: no byte of this backup is staged on siriussec + # (the node runs close to DiskPressure and `local-path` lives on it). + set -euo pipefail + + # alpine/k8s ships kubectl/bash but not rsync/ssh; install them per run + # (~2 s). Nothing else is needed: the DB dumps run inside the CNPG pod. + if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then + echo "== installing rsync + openssh-client" + apk add --no-cache rsync openssh-client >/dev/null + fi + + BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} + BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} + CNPG_TARGETS=${CNPG_TARGETS:-"forgejo/pg sirius-growth/portal"} + DATA_SRC=${DATA_SRC:-/src} + DATA_KEEP=${DATA_KEEP:-7} + DB_KEEP=${DB_KEEP:-14} + MIN_FREE_GB=${MIN_FREE_GB:-8} + STAMP=${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)} + + SSH_OPTS=(-i /keys/id_ed25519 + -o UserKnownHostsFile=/keys/known_hosts + -o StrictHostKeyChecking=yes + -o BatchMode=yes + -o ConnectTimeout=20 + -o ServerAliveInterval=30) + ssh_r() { ssh "${SSH_OPTS[@]}" "$BACKUP_HOST" "$@"; } + + echo "== target: $BACKUP_HOST:$BACKUP_DIR stamp=$STAMP" + ssh_r "mkdir -p '$BACKUP_DIR/forgejo-data' '$BACKUP_DIR/db' '$BACKUP_DIR/manifests'" + avail_gb=$(ssh_r "df -Pk '$BACKUP_DIR' | awk 'NR==2{printf \"%d\", \$4/1048576}'") + avail_gb=${avail_gb:-0} + echo "== remote free space: ${avail_gb} GiB (minimum ${MIN_FREE_GB} GiB)" + if [ "$avail_gb" -lt "$MIN_FREE_GB" ]; then + echo "FAIL: not enough free space on $BACKUP_HOST" + exit 1 + fi + + # First run: --link-dest needs an existing directory to compare against. + ssh_r "cd '$BACKUP_DIR/forgejo-data' && [ -e latest ] || { mkdir -p .empty && ln -sfn .empty latest; }" + + echo "== forgejo-data: /src -> forgejo-data/$STAMP (incremental, link-dest)" + # Forgejo keeps writing while this runs, so a repack/upload can vanish + # mid-copy: rsync reports that as exit 24. That is expected on a live + # instance; anything else (23 = partial transfer, 11/12 = protocol) is a + # real failure. The two transient upload spools are excluded for the same + # reason — they hold half-written packages, never restorable state. + rc=0 + rsync -a --numeric-ids --delete --stats --link-dest=../latest \ + --exclude=/gitea/data/tmp/ \ + --exclude=/gitea/data/repo-archive/tmp/ \ + -e "ssh ${SSH_OPTS[*]}" \ + "$DATA_SRC/" "$BACKUP_HOST:$BACKUP_DIR/forgejo-data/$STAMP/" || rc=$? + case "$rc" in + 0) ;; + 24) echo "== rsync exit 24: files changed during the copy (expected on a live Forgejo)" ;; + *) echo "FAIL: rsync exit $rc"; exit "$rc" ;; + esac + ssh_r "cd '$BACKUP_DIR/forgejo-data' && ln -sfn '$STAMP' latest && du -sh '$STAMP'" + + echo "== databases" + for target in $CNPG_TARGETS; do + ns=${target%%/*} + cluster=${target##*/} + pod=$(kubectl -n "$ns" get cluster "$cluster" -o jsonpath='{.status.currentPrimary}') + db=$(kubectl -n "$ns" get cluster "$cluster" -o jsonpath='{.spec.bootstrap.initdb.database}') + if [ -z "$pod" ] || [ -z "$db" ]; then + echo "FAIL: $ns/$cluster has no currentPrimary/initdb database" + exit 1 + fi + out="$BACKUP_DIR/db/$ns-$cluster-$STAMP.dump" + echo "-- $ns/$cluster primary=$pod db=$db -> $out" + sha_file=$(mktemp) + kubectl -n "$ns" exec -c postgres "$pod" -- \ + pg_dump -U postgres -d "$db" -Fc -Z6 \ + | tee >(sha256sum | awk '{print $1}' > "$sha_file") \ + | ssh_r "cat > '$out.part'" + local_sha=$(cat "$sha_file"); rm -f "$sha_file" + remote_sha=$(ssh_r "sha256sum '$out.part' | awk '{print \$1}'") + if [ -z "$local_sha" ] || [ "$local_sha" != "$remote_sha" ]; then + echo "FAIL: sha256 mismatch for $out (local=${local_sha:-none} remote=${remote_sha:-none})" + exit 1 + fi + ssh_r "mv '$out.part' '$out'" + echo " sha256=$local_sha" + ssh_r "ls -l '$out'" + done + + echo "== manifest" + ssh_r "cd '$BACKUP_DIR' && { echo \"stamp $STAMP\"; echo \"host \$(hostname -s)\"; \ + echo '--- forgejo-data/latest'; du -shL forgejo-data/latest; \ + echo '--- db'; sha256sum db/*-$STAMP.dump; \ + echo '--- db listing'; ls -l db; } > manifests/$STAMP.txt && cat manifests/$STAMP.txt" + + echo "== retention: last $DATA_KEEP data snapshots, last $DB_KEEP dump files" + ssh_r "cd '$BACKUP_DIR/forgejo-data' && ls -1dt 20* 2>/dev/null | tail -n +$((DATA_KEEP + 1)) | xargs -r rm -rf" + ssh_r "cd '$BACKUP_DIR/db' && ls -1t *.dump 2>/dev/null | tail -n +$((DB_KEEP + 1)) | xargs -r rm -f" + ssh_r "cd '$BACKUP_DIR/manifests' && ls -1t *.txt 2>/dev/null | tail -n +$((DB_KEEP + 1)) | xargs -r rm -f" + ssh_r "df -h '$BACKUP_DIR' | tail -1" + + echo "RESULT=success stamp=$STAMP" +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: cluster-backup + namespace: forgejo + labels: + app: cluster-backup +spec: + # UTC everywhere, same convention as every other CronJob in this repo. + schedule: "37 2 * * *" + timeZone: "Etc/UTC" + concurrencyPolicy: Forbid + # Missed by more than 30 min (cluster down / node rebooting): skip the night + # instead of starting a mirror at a random time. + startingDeadlineSeconds: 1800 + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + # First full mirror of an 18 GiB PVC measured ~15 MB/s over WireGuard + # (~20 min); two hours leaves room for a slow night without being killed + # half-way through a snapshot. + activeDeadlineSeconds: 7200 + backoffLimit: 1 + template: + metadata: + labels: + app: cluster-backup + spec: + restartPolicy: Never + serviceAccountName: cluster-backup + # The forgejo-data PVC is local-path on siriussec; the pod must run + # where the volume is. + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: backup + # alpine/k8s carries kubectl 1.36.4 (== cluster version) so the + # CNPG dumps can be taken through the exec API; rsync + openssh + # are added at start (the pod has normal egress). + image: alpine/k8s:1.36.4 + imagePullPolicy: IfNotPresent + command: ["/bin/bash", "/scripts/backup.sh"] + env: + - name: BACKUP_HOST + value: root@10.10.0.5 + - name: BACKUP_DIR + value: /root/cluster-backup + - name: CNPG_TARGETS + value: "forgejo/pg sirius-growth/portal" + - name: DATA_KEEP + value: "7" + - name: DB_KEEP + value: "14" + volumeMounts: + - name: forgejo-data + mountPath: /src + readOnly: true + - name: keys + mountPath: /keys + readOnly: true + - name: scripts + mountPath: /scripts + readOnly: true + resources: + requests: + cpu: 100m + memory: 128Mi + limits: + # Streaming only — this is a hard cap so a regression can + # never stage the 18 GiB PVC on the T480's root filesystem. + ephemeral-storage: 1Gi + memory: 512Mi + volumes: + - name: forgejo-data + persistentVolumeClaim: + claimName: forgejo-data + readOnly: true + - name: keys + secret: + secretName: cluster-backup-ssh + defaultMode: 0400 + - name: scripts + configMap: + name: cluster-backup-scripts + defaultMode: 0755 diff --git a/apps/base/forgejo/kustomization.yaml b/apps/base/forgejo/kustomization.yaml index 6413743..709c518 100644 --- a/apps/base/forgejo/kustomization.yaml +++ b/apps/base/forgejo/kustomization.yaml @@ -18,3 +18,6 @@ resources: - runner-amd64.yaml - runner-deploy-arm64.yaml - prune-cronjob.yaml + # Nightly disaster-recovery backup of forgejo-data + every CNPG database to + # the Linode VPS. Lives here because a PVC cannot be mounted cross-namespace. + - cluster-backup.yaml diff --git a/apps/base/sirius-growth/backup-exec-rbac.yaml b/apps/base/sirius-growth/backup-exec-rbac.yaml new file mode 100644 index 0000000..8e55fc8 --- /dev/null +++ b/apps/base/sirius-growth/backup-exec-rbac.yaml @@ -0,0 +1,41 @@ +--- +# Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of this +# namespace's CloudNativePG cluster through the exec API (namespace `forgejo` +# cannot mount a Secret from here, and the dump runs as the in-pod `postgres` +# superuser over the local socket, so no database password exists in git). +# +# Least privilege: that ServiceAccount may look up the Cluster object and run +# one command inside this namespace's pods — nothing else. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: cluster-backup + namespace: sirius-growth + labels: + app: cluster-backup +rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list"] + - apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create"] + - apiGroups: ["postgresql.cnpg.io"] + resources: ["clusters"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: cluster-backup + namespace: sirius-growth + labels: + app: cluster-backup +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: cluster-backup +subjects: + - kind: ServiceAccount + name: cluster-backup + namespace: forgejo diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index af13e54..1c16380 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -19,3 +19,6 @@ resources: - pvc-leadgen.yaml - cronjob-leadgen.yaml - cronjob-leadgen-ncda.yaml + # exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's CNPG + # cluster (portal) without copying a database password across namespaces. + - backup-exec-rbac.yaml diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index f7b7ac4..e082b05 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -481,16 +481,95 @@ StorageClass `local-path` (default, `WaitForFirstConsumer`, no expansion), provi | PVC | NS | Size | On-disk dir | Used | Holds | |---|---|---|---|---|---| -| `forgejo-data` | forgejo | 20 Gi | `pvc-75ba7bc3…_forgejo_forgejo-data` | **12 G** | Forgejo repos, LFS, avatars, attachments — **must be backed up** | -| `forgejo-runner-amd64` | forgejo | 20 Gi | `pvc-b867904c…_forgejo_forgejo-runner-amd64` | **18 G** (18 G of it the dind `/docker` data-root) | CI scratch — **disposable**, but see the hazard below | -| `pg-1` | forgejo | 10 Gi | `pvc-3c0ba824…_forgejo_pg-1` | 643 M | Forgejo Postgres data — **must be backed up** | -| `portal-1` | sirius-growth | 5 Gi | `pvc-3348c52c…_sirius-growth_portal-1` | 224 M | SGS portal Postgres data — **must be backed up** | +| `forgejo-data` | forgejo | 20 Gi | `pvc-75ba7bc3…_forgejo_forgejo-data` | **19 G** | Forgejo repos, LFS, avatars, attachments (13.6 G of that is package-registry blobs) — **backed up nightly** | +| `forgejo-runner-amd64` | forgejo | 20 Gi | `pvc-b867904c…_forgejo_forgejo-runner-amd64` | **22 G** (the dind `/docker` data-root) | CI scratch — **disposable**, but see the hazard below | +| `pg-1` | forgejo | 10 Gi | `pvc-3c0ba824…_forgejo_pg-1` | 653 M | Forgejo Postgres data — **backed up nightly (pg_dump)** | +| `portal-1` | sirius-growth | 5 Gi | `pvc-3348c52c…_sirius-growth_portal-1` | 595 M | SGS portal Postgres data — **backed up nightly (pg_dump)** | +| `osint-pgdata` / `osint-camera-snapshots` | osint | 15 Gi / 3 Gi | — | 289 M / 4 K | plain Postgres + camera snapshots — **no backup job (gap)** | +| `sgs-leadgen-data` | sirius-growth | 1 Gi | — | 4.9 M | lead-gen capture — **no backup job (gap)** | +| `kube-prometheus-stack-grafana` | monitoring | 5 Gi | — | 55 M | Grafana sqlite (dashboards, alert rules) — **no backup job (gap)** | +| `…prometheus-…-db-…prometheus-0` | monitoring | 10 Gi | — | 2.4 G | Prometheus TSDB — rebuildable metrics history, **not backed up** | -**Dind growth hazard.** The amd64 runner's PVC is nominally 20 Gi and currently sits at **18 G (90%)**. It has previously grown to ~50 GB from heavy Android/Rust builds and pushed the node into `DiskPressure`, which evicted the runner and left Forgejo and `pg-1` Pending. Docker image GC does not reclaim the data-root. Rule: when it approaches the cap, scale the runner to 0 **first**, then wipe `.../docker/*` (keeping `runner.ini` beside it), then scale back and re-pull the job image — wiping it under a live or restarting pod leaves `dockerd` half-initialised and every pull fails. Note the data-root also hosts the named volumes CI depends on (`cargo-target`, Android SDK, Gradle cache), so a wipe makes the next run fully cold. +**Dind growth hazard.** The amd64 runner's PVC is nominally 20 Gi and currently sits at **~22 G**: it has previously grown to ~50 GB from heavy Android/Rust builds and pushed the node into `DiskPressure`, which evicted the runner and left Forgejo and `pg-1` Pending. Docker image GC does not reclaim the data-root. Rule: when it approaches the cap, scale the runner to 0 **first**, then wipe `.../docker/*` (keeping `runner.ini` beside it), then scale back and re-pull the job image — wiping it under a live or restarting pod leaves `dockerd` half-initialised and every pull fails. Note the data-root also hosts the named volumes CI depends on (`cargo-target`, Android SDK, Gradle cache), so a wipe makes the next run fully cold. -**What must be backed up:** `forgejo-data`, both Postgres data dirs (`pg-1`, `portal-1`), the Pi's Garage `data/` + `meta/`, and `/etc/wireguard/` on the Pi. The runner PVC and the Pi's Docker images are rebuildable. +Host disks *(live)*: siriussec `/` 214 G, 167 G used (**83 %**, 37 G free); rpi `/` 917 G, 506 G used (58 %, 374 G free); linode `/` 79 G, 11 G used (**14 %**, 64 G free — this is the backup target). + +### 8.1 Backup coverage + +Two independent nightly paths, both **off** the T480 and **off** the Pi: + +1. **Cluster state → Linode VPS**, CronJob `forgejo/cluster-backup` + (`apps/base/forgejo/cluster-backup.yaml`; exec-only RBAC in + `apps/base/sirius-growth/backup-exec-rbac.yaml`). Schedule `37 2 * * *` + UTC, `concurrencyPolicy: Forbid`. Destination is + `root@10.10.0.5:/root/cluster-backup` — **the mesh address, never the public + IP**. Everything is streamed: no dump is staged on siriussec. +2. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/` + `garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) → + `root@10.20.0.1:/root/garage-backup`. + +| Artifact | Method | On the Linode | Retention | +|---|---|---|---| +| `forgejo-data` PVC (`/data`) | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `forgejo-data//` + `latest` symlink | 7 snapshots (hardlinked: 1 full copy + nightly deltas) | +| `forgejo/pg` | `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket — no DB password exists in git or in the Job | `db/forgejo-pg-.dump` | 14 | +| `sirius-growth/portal` | same, through exec RBAC in `sirius-growth` | `db/sirius-growth-portal-.dump` | 14 | + +- The data mirror is a *snapshot* mirror, not a rolling one: each night writes a + new directory whose unchanged files are hardlinks to the previous night's, so + a corrupted file in the source cannot rewrite history. +- DB dumps are checksummed on **both** sides (`sha256sum` on the pod's copy of + the stream vs the remote file) before the `.part` file is renamed; a short + stream fails the Job instead of silently shipping a broken archive. +- Each run appends sizes + checksums to `/root/cluster-backup/manifests/.txt`. +- The only secret is the backup SSH key: `forgejo/cluster-backup-ssh` (created + out of band, **not in git**, so Flux never reverts it) holding an ed25519 key + that is `from="10.10.0.0/24,10.244.0.0/16,10.20.0.0/24"`-restricted, + `no-pty`, no forwarding in `root@linode:~/.ssh/authorized_keys`. Host key is + pinned (`known_hosts` for `10.10.0.5`), so a MITM on the mesh fails closed. +- The Job lives in namespace `forgejo` (not a `backup` namespace) because a PVC + cannot be mounted cross-namespace and `forgejo-data` is the largest artifact. + +**Not covered — honest gaps:** + +- `monitoring/kube-prometheus-stack-grafana` (55 MiB sqlite: dashboards, alert + rules) — **no backup**. Prometheus' 2.4 GiB TSDB is deliberately excluded + (regenerated metrics history). +- `osint/osint-pgdata` (289 MiB, a plain Postgres **Deployment**, not CNPG) and + `osint/osint-camera-snapshots`, `sirius-growth/sgs-leadgen-data` (4.9 MiB) — + **no backup**. +- `/etc/wireguard/` on the Pi — still only on the Pi (wgportal's sqlite is the + live source; a Pi disk loss takes the peer set with it). +- The runner PVCs (`forgejo-runner-amd64`, `*-dind`) are CI scratch, rebuildable + by design (the dind data-root only holds named build caches). + +A new CloudNativePG cluster is **not** picked up automatically: add +`/` to `CNPG_TARGETS` in the CronJob env *and* an equivalent +exec-only Role/RoleBinding for the `forgejo/cluster-backup` ServiceAccount in +that namespace. + +### 8.2 Restoring + +Rehearsed on 2026-11-19 (see the completion note on task `t_dcad85f6`); the DB +restore below was exercised against a throwaway Postgres pod and produced the +live row count. + +```bash +# 1. Forgejo data: stop Forgejo, then mirror the newest snapshot back. +kubectl -n forgejo scale deploy/forgejo --replicas=0 +# on the node holding the PVC (siriussec), or from any pod that mounts it: +# rsync -a --delete root@10.10.0.5:/root/cluster-backup/forgejo-data/latest/ /data/ +kubectl -n forgejo scale deploy/forgejo --replicas=1 + +# 2. A CNPG database: pull the dump and restore it with pg_restore, e.g. into a +# scratch pod or a scratch database on the cluster: +ssh root@10.10.0.5 'cat /root/cluster-backup/db/forgejo-pg-.dump' \ + | kubectl -n forgejo exec -i -c postgres -- \ + pg_restore -U postgres -d --no-owner --no-privileges +``` + +`pg_restore` is **not** installed on the Linode — pull the dump and restore with +a Postgres client (the `ghcr.io/cloudnative-pg/postgresql:16` primary has one). -Host disks *(live)*: siriussec `/` 214 G, 141 G used (**70%**, 62 G free); rpi `/` 917 G, 506 G used (58%, 374 G free). --- From 3a8c17aa5e698c85f0305fa26d6c28f9ef38caa8 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 17:01:52 -0500 Subject: [PATCH 51/88] docs(cluster-overview): note the backup job's free-space guard --- docs/cluster-overview.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index e082b05..a830994 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -521,6 +521,8 @@ Two independent nightly paths, both **off** the T480 and **off** the Pi: the stream vs the remote file) before the `.part` file is renamed; a short stream fails the Job instead of silently shipping a broken archive. - Each run appends sizes + checksums to `/root/cluster-backup/manifests/.txt`. +- The Job fails (a red Job, not a silent skip) if the Linode has less than + 8 GiB free, so a growing registry cannot quietly eat the last snapshot's room. - The only secret is the backup SSH key: `forgejo/cluster-backup-ssh` (created out of band, **not in git**, so Flux never reverts it) holding an ed25519 key that is `from="10.10.0.0/24,10.244.0.0/16,10.20.0.0/24"`-restricted, From c1fe485469b8958fedbf8fca36e0aff86b09d004 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 17:14:36 -0500 Subject: [PATCH 52/88] apps(backup): cover the remaining stateful gaps off-host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four pieces of state were still only on the machine they run on. All four now land on the Linode over the WireGuard mesh, in the same /root/cluster-backup tree (or /root/pihost-backup for the Pi) with the same manifest/sha256 habit: * monitoring/kube-prometheus-stack-grafana — new CronJob `monitoring/grafana-backup`. The image is -distroless (no shell), so this mounts the PVC read-write and takes a consistent copy with the sqlite backup API (PRAGMA integrity_check on the copy), then streams it: grafana/grafana-.db, keep 14. * osint/osint-db — plain Postgres Deployment, so neither the CNPG primary lookup nor CNPG_TARGETS reaches it. `forgejo/cluster-backup` gains a PG_TARGETS loop that pg_dump -Fc's inside the pod using its own POSTGRES_USER/POSTGRES_DB (exec-only RBAC in apps/base/osint/), sha256 checked on both sides. * sirius-growth/sgs-leadgen-data — new CronJob `sirius-growth/leadgen-backup`, link-dest snapshot mirror, keep 7. * Pi /etc/wireguard + wgportal sqlite — infrastructure/wireguard/backup/, nightly systemd timer -> root@10.20.0.1:/root/pihost-backup, keep 14. Each tree carries its own retention, so adding artifacts cannot crowd the Linode. Docs §8/§8.1/§8.2 record coverage, the accepted gaps (Prometheus TSDB, camera frames, runner scratch) and the restore procedure — including the TimescaleDB pre/post-restore calls osint needs. --- apps/base/forgejo/cluster-backup.yaml | 35 +++- apps/base/osint/backup-exec-rbac.yaml | 46 +++++ apps/base/osint/kustomization.yaml | 3 + apps/base/sirius-growth/kustomization.yaml | 2 + apps/base/sirius-growth/leadgen-backup.yaml | 150 +++++++++++++++ docs/cluster-overview.md | 90 +++++++-- infrastructure/wireguard/backup/README.md | 82 ++++++++ .../wireguard/backup/wireguard-backup.service | 18 ++ .../wireguard/backup/wireguard-backup.sh | 110 +++++++++++ .../wireguard/backup/wireguard-backup.timer | 13 ++ .../controllers/home/grafana-backup.yaml | 178 ++++++++++++++++++ .../controllers/home/kustomization.yaml | 2 + 12 files changed, 712 insertions(+), 17 deletions(-) create mode 100644 apps/base/osint/backup-exec-rbac.yaml create mode 100644 apps/base/sirius-growth/leadgen-backup.yaml create mode 100644 infrastructure/wireguard/backup/README.md create mode 100644 infrastructure/wireguard/backup/wireguard-backup.service create mode 100644 infrastructure/wireguard/backup/wireguard-backup.sh create mode 100644 infrastructure/wireguard/backup/wireguard-backup.timer create mode 100644 monitoring/controllers/home/grafana-backup.yaml diff --git a/apps/base/forgejo/cluster-backup.yaml b/apps/base/forgejo/cluster-backup.yaml index 1e7386c..5b1518d 100644 --- a/apps/base/forgejo/cluster-backup.yaml +++ b/apps/base/forgejo/cluster-backup.yaml @@ -1,6 +1,7 @@ --- # Nightly backup of every piece of state on this cluster that is not -# rebuildable from git: Forgejo's data PVC and the CloudNativePG databases. +# rebuildable from git: Forgejo's data PVC, the CloudNativePG databases and the +# plain Postgres Deployment in `osint`. # # Why this lives in namespace `forgejo` (and not a `backup` namespace): # the biggest artifact is the `forgejo-data` PVC, and a Kubernetes volume @@ -96,6 +97,11 @@ data: BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} CNPG_TARGETS=${CNPG_TARGETS:-"forgejo/pg sirius-growth/portal"} + # Plain (non-CNPG) Postgres Deployments: /. There is + # no Cluster CR to ask for a primary, and no superuser path from outside, so + # the dump runs inside the pod and reads its own POSTGRES_USER/POSTGRES_DB + # (local socket, trust auth) — no password in git or in this Job. + PG_TARGETS=${PG_TARGETS:-"osint/osint-db"} DATA_SRC=${DATA_SRC:-/src} DATA_KEEP=${DATA_KEEP:-7} DB_KEEP=${DB_KEEP:-14} @@ -143,6 +149,8 @@ data: ssh_r "cd '$BACKUP_DIR/forgejo-data' && ln -sfn '$STAMP' latest && du -sh '$STAMP'" echo "== databases" + # A previous run killed mid-stream can leave a zero-byte `.part` behind. + ssh_r "find '$BACKUP_DIR/db' -name '*.part' -mmin +60 -delete 2>/dev/null || true" for target in $CNPG_TARGETS; do ns=${target%%/*} cluster=${target##*/} @@ -170,6 +178,29 @@ data: ssh_r "ls -l '$out'" done + echo "== plain Postgres deployments" + for target in $PG_TARGETS; do + ns=${target%%/*} + deploy=${target##*/} + out="$BACKUP_DIR/db/$ns-$deploy-$STAMP.dump" + echo "-- $ns/$deploy -> $out" + sha_file=$(mktemp) + kubectl -n "$ns" exec "deploy/$deploy" -- \ + sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc -Z6' \ + | tee >(sha256sum | awk '{print $1}' > "$sha_file") \ + | ssh_r "cat > '$out.part'" + local_sha=$(cat "$sha_file"); rm -f "$sha_file" + remote_sha=$(ssh_r "sha256sum '$out.part' | awk '{print \$1}'") + if [ -z "$local_sha" ] || [ "$local_sha" != "$remote_sha" ]; then + echo "FAIL: sha256 mismatch for $out (local=${local_sha:-none} remote=${remote_sha:-none})" + ssh_r "rm -f '$out.part'" + exit 1 + fi + ssh_r "mv '$out.part' '$out'" + echo " sha256=$local_sha" + ssh_r "ls -l '$out'" + done + echo "== manifest" ssh_r "cd '$BACKUP_DIR' && { echo \"stamp $STAMP\"; echo \"host \$(hostname -s)\"; \ echo '--- forgejo-data/latest'; du -shL forgejo-data/latest; \ @@ -234,6 +265,8 @@ spec: value: /root/cluster-backup - name: CNPG_TARGETS value: "forgejo/pg sirius-growth/portal" + - name: PG_TARGETS + value: "osint/osint-db" - name: DATA_KEEP value: "7" - name: DB_KEEP diff --git a/apps/base/osint/backup-exec-rbac.yaml b/apps/base/osint/backup-exec-rbac.yaml new file mode 100644 index 0000000..e2a691d --- /dev/null +++ b/apps/base/osint/backup-exec-rbac.yaml @@ -0,0 +1,46 @@ +--- +# Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of the +# plain (non-CNPG) Postgres Deployment `osint/osint-db` through the exec API. +# +# `osint-db` is a stock `postgres` Deployment, so there is no Cluster object and +# no `status.currentPrimary` to look up; the dump is taken inside the pod over +# the local socket and uses the pod's own `POSTGRES_USER`/`POSTGRES_DB`, so no +# password is copied into `forgejo`, git or the Job. +# +# Least privilege: the ServiceAccount may run one command inside this +# namespace's pods — nothing else. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: cluster-backup + namespace: osint + labels: + app: cluster-backup +rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list"] + - apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create"] + # `kubectl exec deploy/osint-db` resolves the Deployment's ReplicaSet/pod, so + # it needs read access to the deployment itself. + - apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: cluster-backup + namespace: osint + labels: + app: cluster-backup +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: cluster-backup +subjects: + - kind: ServiceAccount + name: cluster-backup + namespace: forgejo diff --git a/apps/base/osint/kustomization.yaml b/apps/base/osint/kustomization.yaml index af3ccdf..e002a5c 100644 --- a/apps/base/osint/kustomization.yaml +++ b/apps/base/osint/kustomization.yaml @@ -18,3 +18,6 @@ resources: - news-scraper-deployment.yaml - news-summarizer-deployment.yaml - httproute.yaml + # exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's plain + # Postgres Deployment (osint-db) — not a CNPG cluster, so it needs its own path. + - backup-exec-rbac.yaml diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index 1c16380..0719d16 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -22,3 +22,5 @@ resources: # exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's CNPG # cluster (portal) without copying a database password across namespaces. - backup-exec-rbac.yaml + # Snapshot mirror of the lead-gen capture PVC to the Linode. + - leadgen-backup.yaml diff --git a/apps/base/sirius-growth/leadgen-backup.yaml b/apps/base/sirius-growth/leadgen-backup.yaml new file mode 100644 index 0000000..70aa0cf --- /dev/null +++ b/apps/base/sirius-growth/leadgen-backup.yaml @@ -0,0 +1,150 @@ +--- +# backup: `sgs-leadgen-data` PVC (4.9 MiB) -> Linode VPS over the WireGuard mesh. +# +# The lead-gen CronJobs (`cronjob-leadgen.yaml`, `cronjob-leadgen-ncda.yaml`) +# read and write this claim, so a pod of this namespace must mount it — a PVC +# cannot be mounted from `forgejo` where the main cluster-backup job lives. +# The mirror is a hardlink `--link-dest` snapshot chain (same shape as the +# forgejo-data mirror) so each night is a full restorable directory and only +# changed blocks cross the tunnel. +apiVersion: v1 +kind: ConfigMap +metadata: + name: leadgen-backup-scripts + namespace: sirius-growth + labels: + app: leadgen-backup +data: + backup.sh: | + #!/bin/bash + # Snapshot mirror of /src -> $BACKUP_DIR/leadgen-data// + `latest`. + set -euo pipefail + + if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then + echo "== installing rsync + openssh-client" + apk add --no-cache rsync openssh-client >/dev/null + fi + + BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} + BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} + DATA_SRC=${DATA_SRC:-/src} + DATA_KEEP=${DATA_KEEP:-7} + MIN_FREE_GB=${MIN_FREE_GB:-8} + STAMP=${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)} + + SSH_OPTS=(-i /keys/id_ed25519 + -o UserKnownHostsFile=/keys/known_hosts + -o StrictHostKeyChecking=yes + -o BatchMode=yes + -o ConnectTimeout=20 + -o ServerAliveInterval=30) + ssh_r() { ssh "${SSH_OPTS[@]}" "$BACKUP_HOST" "$@"; } + + echo "== target: $BACKUP_HOST:$BACKUP_DIR stamp=$STAMP" + ssh_r "mkdir -p '$BACKUP_DIR/leadgen-data' '$BACKUP_DIR/manifests'" + avail_gb=$(ssh_r "df -Pk '$BACKUP_DIR' | awk 'NR==2{printf \"%d\", \$4/1048576}'") + avail_gb=${avail_gb:-0} + echo "== remote free space: ${avail_gb} GiB (minimum ${MIN_FREE_GB} GiB)" + if [ "$avail_gb" -lt "$MIN_FREE_GB" ]; then + echo "FAIL: not enough free space on $BACKUP_HOST" + exit 1 + fi + + ssh_r "cd '$BACKUP_DIR/leadgen-data' && [ -e latest ] || { mkdir -p .empty && ln -sfn .empty latest; }" + + echo "== leadgen-data: $DATA_SRC -> leadgen-data/$STAMP (link-dest)" + rc=0 + rsync -a --numeric-ids --delete --stats --link-dest=../latest \ + -e "ssh ${SSH_OPTS[*]}" \ + "$DATA_SRC/" "$BACKUP_HOST:$BACKUP_DIR/leadgen-data/$STAMP/" || rc=$? + case "$rc" in + 0) ;; + 24) echo "== rsync exit 24: files changed during the copy (expected)" ;; + *) echo "FAIL: rsync exit $rc"; exit "$rc" ;; + esac + ssh_r "cd '$BACKUP_DIR/leadgen-data' && ln -sfn '$STAMP' latest && du -sh '$STAMP'" + + echo "== manifest" + ssh_r "cd '$BACKUP_DIR' && { echo 'stamp $STAMP'; echo \"host \$(hostname -s)\"; \ + echo '--- leadgen-data/latest'; du -shL leadgen-data/latest; \ + find leadgen-data/latest -type f -exec sha256sum {} + | sed 's| leadgen-data/latest/| |'; } \ + >> manifests/$STAMP.txt && tail -8 manifests/$STAMP.txt" + + echo "== retention: last $DATA_KEEP leadgen snapshots" + ssh_r "cd '$BACKUP_DIR/leadgen-data' && ls -1dt 20* 2>/dev/null | tail -n +$((DATA_KEEP + 1)) | xargs -r rm -rf" + ssh_r "df -h '$BACKUP_DIR' | tail -1" + + echo "RESULT=success stamp=$STAMP" +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: leadgen-backup + namespace: sirius-growth + labels: + app: leadgen-backup +spec: + # 07 minutes after the grafana job; the dataset is tiny, this is only so the + # three nightly jobs never overlap on the mesh. + schedule: "7 3 * * *" + timeZone: "Etc/UTC" + concurrencyPolicy: Forbid + startingDeadlineSeconds: 1800 + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + activeDeadlineSeconds: 900 + backoffLimit: 1 + template: + metadata: + labels: + app: leadgen-backup + spec: + restartPolicy: Never + # The PVC is local-path on siriussec. + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: backup + image: alpine/k8s:1.36.4 + imagePullPolicy: IfNotPresent + command: ["/bin/bash", "/scripts/backup.sh"] + env: + - name: BACKUP_HOST + value: root@10.10.0.5 + - name: BACKUP_DIR + value: /root/cluster-backup + - name: DATA_KEEP + value: "7" + volumeMounts: + - name: leadgen-data + mountPath: /src + readOnly: true + - name: keys + mountPath: /keys + readOnly: true + - name: scripts + mountPath: /scripts + readOnly: true + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + ephemeral-storage: 512Mi + memory: 256Mi + volumes: + - name: leadgen-data + persistentVolumeClaim: + claimName: sgs-leadgen-data + readOnly: true + - name: keys + secret: + # Copy of forgejo/cluster-backup-ssh, created out of band. + secretName: cluster-backup-ssh + defaultMode: 0400 + - name: scripts + configMap: + name: leadgen-backup-scripts + defaultMode: 0755 diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index a830994..54823b8 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -485,9 +485,9 @@ StorageClass `local-path` (default, `WaitForFirstConsumer`, no expansion), provi | `forgejo-runner-amd64` | forgejo | 20 Gi | `pvc-b867904c…_forgejo_forgejo-runner-amd64` | **22 G** (the dind `/docker` data-root) | CI scratch — **disposable**, but see the hazard below | | `pg-1` | forgejo | 10 Gi | `pvc-3c0ba824…_forgejo_pg-1` | 653 M | Forgejo Postgres data — **backed up nightly (pg_dump)** | | `portal-1` | sirius-growth | 5 Gi | `pvc-3348c52c…_sirius-growth_portal-1` | 595 M | SGS portal Postgres data — **backed up nightly (pg_dump)** | -| `osint-pgdata` / `osint-camera-snapshots` | osint | 15 Gi / 3 Gi | — | 289 M / 4 K | plain Postgres + camera snapshots — **no backup job (gap)** | -| `sgs-leadgen-data` | sirius-growth | 1 Gi | — | 4.9 M | lead-gen capture — **no backup job (gap)** | -| `kube-prometheus-stack-grafana` | monitoring | 5 Gi | — | 55 M | Grafana sqlite (dashboards, alert rules) — **no backup job (gap)** | +| `osint-pgdata` / `osint-camera-snapshots` | osint | 15 Gi / 3 Gi | — | 289 M / 4 K | plain Postgres — **backed up nightly (pg_dump)**; the camera snapshot dir is 4 K of throwaway frames — **accepted gap** | +| `sgs-leadgen-data` | sirius-growth | 1 Gi | — | 4.9 M | lead-gen capture — **mirrored nightly** | +| `kube-prometheus-stack-grafana` | monitoring | 5 Gi | — | 55 M | Grafana sqlite: users/orgs/prefs/API keys/annotations (dashboards, datasources and alert rules are provisioned from git, so they are *not* in the db) — **snapshotted nightly** | | `…prometheus-…-db-…prometheus-0` | monitoring | 10 Gi | — | 2.4 G | Prometheus TSDB — rebuildable metrics history, **not backed up** | **Dind growth hazard.** The amd64 runner's PVC is nominally 20 Gi and currently sits at **~22 G**: it has previously grown to ~50 GB from heavy Android/Rust builds and pushed the node into `DiskPressure`, which evicted the runner and left Forgejo and `pg-1` Pending. Docker image GC does not reclaim the data-root. Rule: when it approaches the cap, scale the runner to 0 **first**, then wipe `.../docker/*` (keeping `runner.ini` beside it), then scale back and re-pull the job image — wiping it under a live or restarting pod leaves `dockerd` half-initialised and every pull fails. Note the data-root also hosts the named volumes CI depends on (`cargo-target`, Android SDK, Gradle cache), so a wipe makes the next run fully cold. @@ -496,23 +496,38 @@ Host disks *(live)*: siriussec `/` 214 G, 167 G used (**83 %**, 37 G free); rpi ### 8.1 Backup coverage -Two independent nightly paths, both **off** the T480 and **off** the Pi: +Three independent scheduled paths, all **off** the T480 and **off** the Pi: 1. **Cluster state → Linode VPS**, CronJob `forgejo/cluster-backup` (`apps/base/forgejo/cluster-backup.yaml`; exec-only RBAC in - `apps/base/sirius-growth/backup-exec-rbac.yaml`). Schedule `37 2 * * *` + `apps/base/sirius-growth/backup-exec-rbac.yaml` and + `apps/base/osint/backup-exec-rbac.yaml`). Schedule `37 2 * * *` UTC, `concurrencyPolicy: Forbid`. Destination is `root@10.10.0.5:/root/cluster-backup` — **the mesh address, never the public IP**. Everything is streamed: no dump is staged on siriussec. -2. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/` +2. **Two small PVC mirrors into the same tree**, because a PVC can only be + mounted by a pod in its own namespace: `monitoring/grafana-backup` + (`monitoring/controllers/home/grafana-backup.yaml`, `0 3 * * *`) and + `sirius-growth/leadgen-backup` (`apps/base/sirius-growth/leadgen-backup.yaml`, + `7 3 * * *`). Both mount the claim on siriussec and stream to + `root@10.10.0.5:/root/cluster-backup`, so retention and the manifest habit + are shared with path 1. +3. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/` `garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) → `root@10.20.0.1:/root/garage-backup`. +A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` +`wireguard-backup.timer` (nightly 04:13) → `root@10.20.0.1:/root/pihost-backup`. + | Artifact | Method | On the Linode | Retention | |---|---|---|---| | `forgejo-data` PVC (`/data`) | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `forgejo-data//` + `latest` symlink | 7 snapshots (hardlinked: 1 full copy + nightly deltas) | | `forgejo/pg` | `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket — no DB password exists in git or in the Job | `db/forgejo-pg-.dump` | 14 | | `sirius-growth/portal` | same, through exec RBAC in `sirius-growth` | `db/sirius-growth-portal-.dump` | 14 | +| `osint/osint-db` (plain Postgres Deployment, has TimescaleDB + PostGIS) | `pg_dump -Fc -Z6` **inside the pod** over the local socket, using its own `POSTGRES_USER`/`POSTGRES_DB` via exec RBAC in `osint` | `db/osint-osint-db-.dump` | 14 | +| `grafana.db` (sqlite) | **sqlite backup API** in a `python:3.12-alpine` pod that mounts the PVC — a `cp` of a live db can capture a torn page; the image is `-distroless`, so there is no shell to exec into | `grafana/grafana-.db` | 14 | +| `sgs-leadgen-data` PVC | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `leadgen-data//` + `latest` | 7 | +| Pi `/etc/wireguard/` + wgportal `sqlite.db` | Pi-side systemd timer: tarball (`/etc/wireguard` verbatim incl. `.bak` history + a sqlite-API copy of the peer db), sha256 checked on both sides | `root@10.20.0.1:/root/pihost-backup/wireguard/wireguard-.tar.gz` | 14 | - The data mirror is a *snapshot* mirror, not a rolling one: each night writes a new directory whose unchanged files are hardlinks to the previous night's, so @@ -531,18 +546,20 @@ Two independent nightly paths, both **off** the T480 and **off** the Pi: - The Job lives in namespace `forgejo` (not a `backup` namespace) because a PVC cannot be mounted cross-namespace and `forgejo-data` is the largest artifact. -**Not covered — honest gaps:** +**Accepted gaps (with the reason, not just a TODO):** -- `monitoring/kube-prometheus-stack-grafana` (55 MiB sqlite: dashboards, alert - rules) — **no backup**. Prometheus' 2.4 GiB TSDB is deliberately excluded - (regenerated metrics history). -- `osint/osint-pgdata` (289 MiB, a plain Postgres **Deployment**, not CNPG) and - `osint/osint-camera-snapshots`, `sirius-growth/sgs-leadgen-data` (4.9 MiB) — - **no backup**. -- `/etc/wireguard/` on the Pi — still only on the Pi (wgportal's sqlite is the - live source; a Pi disk loss takes the peer set with it). -- The runner PVCs (`forgejo-runner-amd64`, `*-dind`) are CI scratch, rebuildable +- **Prometheus TSDB** (2.4 GiB) — deliberately excluded: regenerated metrics + history, and a volume loss only costs graphs, not state. +- **`osint/osint-camera-snapshots`** (4 K) — throwaway camera frames; the + camera re-captures on demand and nothing reads old frames. +- **Runner PVCs** (`forgejo-runner-amd64`, `*-dind`) — CI scratch, rebuildable by design (the dind data-root only holds named build caches). +- **Grafana dashboards / datasources / alert rules are not in the backup and do + not need to be**: they are provisioned from `monitoring/controllers/home/` + in git. The sqlite db carries the parts git cannot rebuild — users, orgs, + preferences, annotations and API keys. +- **Pi `/etc/wireguard` is only as fresh as the last nightly run** — a peer + added today is in the db and on the Pi, and reaches the Linode at 04:13. A new CloudNativePG cluster is **not** picked up automatically: add `/` to `CNPG_TARGETS` in the CronJob env *and* an equivalent @@ -572,6 +589,47 @@ ssh root@10.10.0.5 'cat /root/cluster-backup/db/forgejo-pg-.dump' \ `pg_restore` is **not** installed on the Linode — pull the dump and restore with a Postgres client (the `ghcr.io/cloudnative-pg/postgresql:16` primary has one). +```bash +# 3. osint-db (plain Postgres **with TimescaleDB**): a naive pg_restore into a +# fresh database fails on hypertable catalog rows ("could not find hypertable +# with id N" / "ONLY option not supported on hypertable operations") and +# silently drops one hypertable's data. Pre/post-restore commands are +# mandatory, and the extensions must exist BEFORE them. +kubectl -n osint exec deploy/osint-db -- psql -U osint -d postgres \ + -c 'create database osint_restore' +kubectl -n osint exec deploy/osint-db -- psql -U osint -d osint_restore \ + -c 'create extension if not exists timescaledb' \ + -c 'create extension if not exists postgis' \ + -c 'select timescaledb_pre_restore()' +ssh root@10.10.0.5 'cat /root/cluster-backup/db/osint-osint-db-.dump' \ + | kubectl -n osint exec -i deploy/osint-db -- \ + pg_restore -U osint -d osint_restore --no-owner --no-privileges +kubectl -n osint exec deploy/osint-db -- psql -U osint -d osint_restore \ + -c 'select timescaledb_post_restore()' + +# 4. Grafana: readable with the sqlite backup API and integrity_check=ok. +# Stop Grafana first (it also runs `strategy: Recreate`) so the restored file +# is not overwritten by the running instance's open handle. +kubectl -n monitoring scale deploy/kube-prometheus-stack-grafana --replicas=0 +ssh root@10.10.0.5 'cat /root/cluster-backup/grafana/grafana-.db' \ + | kubectl -n monitoring exec -i -- \ + sh -c 'cat > /var/lib/grafana/grafana.db && chown 472:472 /var/lib/grafana/grafana.db' +kubectl -n monitoring scale deploy/kube-prometheus-stack-grafana --replicas=1 +# Users come back from the db; dashboards/datasources re-provision from git. + +# 5. Lead-gen capture: plain mirror — pull it back onto the claim with rsync. +rsync -a --delete root@10.10.0.5:/root/cluster-backup/leadgen-data/latest/ /leadgen/ + +# 6. Pi hub state (keys included — pull it to a root-only path, never a shared one). +ssh -i /home/sirius/.ssh/linode_admin root@10.20.0.1 \ + 'cat /root/pihost-backup/wireguard/wireguard-.tar.gz' | sudo tar -tzf - +# stop wg-quick first: SaveConfig = true rewrites wg0.conf from the live iface +sudo wg-quick down wg0 || true +ssh -i /home/sirius/.ssh/linode_admin root@10.20.0.1 \ + 'cat /root/pihost-backup/wireguard/wireguard-.tar.gz' | sudo tar -xzf - -C / +sudo systemctl start wg-quick@wg0 && sudo wg show +``` + --- diff --git a/infrastructure/wireguard/backup/README.md b/infrastructure/wireguard/backup/README.md new file mode 100644 index 0000000..3e04dac --- /dev/null +++ b/infrastructure/wireguard/backup/README.md @@ -0,0 +1,82 @@ +# WireGuard hub state — backup of `/etc/wireguard` + the wgportal peer database + +The Pi (`rpi`, `10.10.0.1`) is the WireGuard **hub** of the mesh *and* a spoke +of the Linode hub (`10.20.0.1`). Two files there are unrebuildable: + +| Path | What it is | +|---|---| +| `/etc/wireguard/wg0.conf` | wgportal-autogenerated hub config: wg0 server key, every peer, every `AllowedIPs` | +| `/etc/wireguard/wg-remote.conf` | the Pi→Linode spoke (key + endpoint) | +| `/opt/wgportal/data/sqlite.db` | wgportal's peer database (identifiers, keys, allowed IPs, display names) | + +A rebuilt Pi comes back from git + Garage's own backup — but the peer set and +the hub key would be gone, and with them every remote-access path. This +directory mirrors `infrastructure/garage/backup/`: a small script plus a +systemd timer that copies the state **off the Pi** to +`root@10.20.0.1:/root/pihost-backup/`. + +## This directory is NOT applied by Flux + +Flux only reconciles `./clusters/homek8s`. Install these by hand (they are host +units, not cluster objects): + +```bash +# from the repo checkout on the Pi (or scp the three files over) +sudo install -m 0755 wireguard-backup.sh /usr/local/sbin/wireguard-backup.sh +sudo install -m 0644 wireguard-backup.service wireguard-backup.timer /etc/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl enable --now wireguard-backup.timer + +# one hand-fired run, and read the result (exit code is the truth) +sudo systemctl start wireguard-backup.service +systemctl status wireguard-backup.service --no-pager +journalctl -u wireguard-backup.service -n 40 --no-pager +``` + +Re-run the install after a Pi reinstall — the units do not survive a reimage. + +## What lands on the Linode + +``` +/root/pihost-backup/wireguard/wireguard-.tar.gz mode 0600 +/root/pihost-backup/manifests/.txt sizes + sha256 +``` + +- One tarball per run (`/etc/wireguard/` verbatim, including the `.bak` peer + history, plus `wgportal-sqlite.db`). Retention: **14** tarballs + 14 + manifests, enforced by the script. +- The sqlite copy is taken with the **sqlite backup API** (python3 stdlib — + there is no `sqlite3` CLI on the Pi), not `cp`: a live `cp` can capture a + half-written page. The script runs `PRAGMA integrity_check` on the copy and + fails the unit if it is not `ok`. +- The tarball is checksummed on both sides before the `.part` file is renamed. +- Transport is the `wg-remote` tunnel using the existing `sirius` user key + (`/home/sirius/.ssh/linode_admin`). Never the Linode public IP. + +## Restore + +The tarball contains private keys — treat it as a secret, not an archive. + +```bash +# pull the newest tarball and inspect it WITHOUT writing to /etc +ssh -i /home/sirius/.ssh/linode_admin root@10.20.0.1 \ + 'ls -1t /root/pihost-backup/wireguard/*.tar.gz | head -1' # pick a stamp +ssh -i /home/sirius/.ssh/linode_admin root@10.20.0.1 \ + 'cat /root/pihost-backup/wireguard/wireguard-.tar.gz' \ + | tar -tzf - + +# restore onto a rebuilt Pi (stop the interfaces first so a running wg-quick +# does not rewrite wg0.conf with SaveConfig = true) +sudo systemctl stop wg-quick@wg-remote || true +sudo wg-quick down wg0 || true +ssh ... 'cat /root/pihost-backup/wireguard/wireguard-.tar.gz' | sudo tar -xzf - -C / +sudo install -m 0600 -o root -g root /dev/null /dev/null # no-op, permissions come from the archive +sudo systemctl start wg-quick@wg0 && sudo systemctl start wg-quick@wg-remote +sudo wg show +``` + +If only wgportal lost its database: extract `wgportal-sqlite.db` from the +tarball, run `PRAGMA integrity_check` on it, and copy it over +`/opt/wgportal/data/sqlite.db` while the wgportal container is stopped — a +portal restart rewrites peers from live `wg set` state, so stop/start it +deliberately rather than leaving it running mid-restore. diff --git a/infrastructure/wireguard/backup/wireguard-backup.service b/infrastructure/wireguard/backup/wireguard-backup.service new file mode 100644 index 0000000..701c661 --- /dev/null +++ b/infrastructure/wireguard/backup/wireguard-backup.service @@ -0,0 +1,18 @@ +# /etc/systemd/system/wireguard-backup.service (rpi) +# +# Hub state -> Linode VPS. The peer set and the wg0 server key are the one +# thing on the Pi that neither Flux nor a git repo can rebuild; a Pi disk loss +# would otherwise take remote access with it. +[Unit] +Description=WireGuard hub state (etc/wireguard + wgportal sqlite) -> Linode VPS +After=network-online.target docker.service +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/local/sbin/wireguard-backup.sh +# A slow tunnel is not a reason to retry a small job forever. +TimeoutStartSec=10min +Nice=10 +# The tarball is an archive of private keys. +UMask=0077 diff --git a/infrastructure/wireguard/backup/wireguard-backup.sh b/infrastructure/wireguard/backup/wireguard-backup.sh new file mode 100644 index 0000000..a2092eb --- /dev/null +++ b/infrastructure/wireguard/backup/wireguard-backup.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +# WireGuard hub-state backup — /etc/wireguard + the wgportal peer database, +# copied OFF the Pi to the Linode VPS over the wg-remote tunnel. +# +# Why this exists: the Pi is the WireGuard *hub*. Its /etc/wireguard carries the +# wg0 server key and every peer's public key/allowed-ips, and wgportal's sqlite +# is the peer database the UI renders. Losing the Pi's disk would take the whole +# remote-access path with it — including the tunnel you would need to fix it. +# +# Destination is 10.20.0.1 (the hub's VPN address), never the public IP, and +# never the Pi itself: a backup on the machine it protects is not a backup. +# Mirrors infrastructure/garage/backup/ in shape (same key, same host, same +# timer/oneshot style). Not managed by Flux — install it with the steps in +# ./README.md. +# +# Run as root (systemd does): /etc/wireguard is 0600 root:root and +# /opt/wgportal/data is 0700 root:root. +# +# Exit code is the truth: the unit is oneshot, so +# `systemctl status wireguard-backup.service` shows the last result. +set -euo pipefail + +KEY=/home/sirius/.ssh/linode_admin +REMOTE=root@10.20.0.1 +DEST=/root/pihost-backup +KEEP=14 +STAGE=/var/lib/pihost-backup +STAMP=${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)} + +# Host key: root on the Pi 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 it later changes; the transport is already an +# authenticated WireGuard tunnel. +SSH="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)" "$*"; } + +log "target check: $($SSH "$REMOTE" 'hostname; df -h / | tail -1')" +$SSH "$REMOTE" "install -d -m 0700 '$DEST' '$DEST/wireguard' '$DEST/manifests'" + +install -d -m 0700 "$STAGE" +work="$STAGE/$STAMP" +rm -rf "$work"; install -d -m 0700 "$work" +trap 'rm -rf "$work"' EXIT + +log "collecting /etc/wireguard" +# Whole directory including the wgportal-autogenerated wg0.conf, wg-remote.conf +# and their .bak history (the .bak files are how old peer sets survive a bad +# SaveConfig rewrite). +cp -a /etc/wireguard "$work/wireguard" + +if [ -f /opt/wgportal/data/sqlite.db ]; then + log "consistent copy of wgportal sqlite" + # A plain cp of a live sqlite file can capture a half-written page; the + # backup API takes a read transaction instead. python3 is on the Pi, there is + # no sqlite3 CLI. + python3 - "$work/wgportal-sqlite.db" <<'PY' +import sqlite3, sys +src = sqlite3.connect("/opt/wgportal/data/sqlite.db", timeout=30) +src.execute("PRAGMA busy_timeout=30000") +dst = sqlite3.connect(sys.argv[1]) +src.backup(dst) +dst.close() +src.close() +chk = sqlite3.connect(sys.argv[1]) +verdict = chk.execute("PRAGMA integrity_check").fetchone()[0] +peers = chk.execute("SELECT count(*) FROM peers").fetchone()[0] +chk.close() +print(" integrity_check=%s peers=%s" % (verdict, peers)) +if verdict != "ok": + sys.exit("FAIL: wgportal sqlite integrity_check returned %r" % verdict) +PY +else + log "WARN: /opt/wgportal/data/sqlite.db missing — backing up /etc/wireguard only" +fi + +log "manifest" +( cd "$work" && find . -type f -printf '%s %p\n' | sort -k2 | sed 's| \./| |' > MANIFEST.sizes + find . -type f ! -name MANIFEST.sha256 -print0 | sort -z | xargs -0 -r sha256sum > MANIFEST.sha256 ) +manifest_text=$(cat "$work/MANIFEST.sizes") + +tarfile="$STAGE/wireguard-$STAMP.tar.gz" +tar -C "$work" -czf "$tarfile" . +local_sha=$(sha256sum "$tarfile" | awk '{print $1}') +local_size=$(wc -c < "$tarfile") +log "shipping $local_size bytes sha256=$local_sha" + +$SSH "$REMOTE" "cat > '$DEST/wireguard/wireguard-$STAMP.tar.gz.part'" < "$tarfile" +remote_sha=$($SSH "$REMOTE" "sha256sum '$DEST/wireguard/wireguard-$STAMP.tar.gz.part' | awk '{print \$1}'") +if [ "$local_sha" != "${remote_sha:-none}" ]; then + echo "FAIL: sha256 mismatch (local=$local_sha remote=${remote_sha:-none})" + $SSH "$REMOTE" "rm -f '$DEST/wireguard/wireguard-$STAMP.tar.gz.part'" + exit 1 +fi +$SSH "$REMOTE" "mv '$DEST/wireguard/wireguard-$STAMP.tar.gz.part' '$DEST/wireguard/wireguard-$STAMP.tar.gz' && \ + chmod 600 '$DEST/wireguard/wireguard-$STAMP.tar.gz'" + +# Remote manifest: sizes + checksums, the same evidence habit as the cluster +# backup job (/root/cluster-backup/manifests/.txt). +{ + printf 'stamp %s\nhost %s\n' "$STAMP" "$(hostname -s)" + printf -- '--- tarball\n%s %s bytes wireguard-%s.tar.gz\n' "$local_sha" "$local_size" "$STAMP" + printf -- '--- contents\n%s\n' "$manifest_text" +} | $SSH "$REMOTE" "cat > '$DEST/manifests/$STAMP.txt'" + +log "retention: last $KEEP tarballs" +$SSH "$REMOTE" "cd '$DEST/wireguard' && ls -1t *.tar.gz 2>/dev/null | tail -n +$((KEEP + 1)) | xargs -r rm -f" +$SSH "$REMOTE" "cd '$DEST/manifests' && ls -1t *.txt 2>/dev/null | tail -n +$((KEEP + 1)) | xargs -r rm -f" +$SSH "$REMOTE" "ls -l '$DEST/wireguard/wireguard-$STAMP.tar.gz'; df -h '$DEST' | tail -1" + +log "RESULT=success stamp=$STAMP" diff --git a/infrastructure/wireguard/backup/wireguard-backup.timer b/infrastructure/wireguard/backup/wireguard-backup.timer new file mode 100644 index 0000000..c67f423 --- /dev/null +++ b/infrastructure/wireguard/backup/wireguard-backup.timer @@ -0,0 +1,13 @@ +# /etc/systemd/system/wireguard-backup.timer (rpi) +[Unit] +Description=Nightly WireGuard hub-state backup + +[Timer] +# 04:13 local time, jittered so it does not race the 03:36 garage-data run. +OnCalendar=*-*-* 04:13:00 +RandomizedDelaySec=600 +Persistent=true +Unit=wireguard-backup.service + +[Install] +WantedBy=timers.target diff --git a/monitoring/controllers/home/grafana-backup.yaml b/monitoring/controllers/home/grafana-backup.yaml new file mode 100644 index 0000000..2da83fb --- /dev/null +++ b/monitoring/controllers/home/grafana-backup.yaml @@ -0,0 +1,178 @@ +--- +# Nightly backup of Grafana's sqlite state (dashboards, alert rules, users, +# annotations) to the Linode VPS over the WireGuard mesh. +# +# Why a Job in this namespace instead of the `forgejo/cluster-backup` exec +# path: the Grafana image is `-distroless` — there is no shell, no `cp`, no +# `tar`, so `kubectl exec` cannot produce a dump. The PVC is on siriussec +# (`local-path`) and RWO still allows a second pod on the same node, so the +# backup pod mounts the volume read-write and takes a *consistent* copy with +# the sqlite backup API (a plain `cp` of a live database can capture a torn +# page or a half-applied transaction). +# +# Layout on the Linode (same tree/retention style as the cluster-backup job): +# /root/cluster-backup/grafana/grafana-.db +# /root/cluster-backup/manifests/.txt (appended by that job's runs) +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-backup-scripts + namespace: monitoring + labels: + app: grafana-backup +data: + backup.sh: | + #!/bin/sh + # Consistent sqlite snapshot -> Linode. Streamed: nothing is staged on the + # T480's root filesystem, the only local file is a ~3 MB copy in /tmp. + set -eu + + if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then + echo "== installing rsync + openssh-client" + apk add --no-cache rsync openssh-client >/dev/null + fi + + BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} + BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} + DB_KEEP=${DB_KEEP:-14} + MIN_FREE_GB=${MIN_FREE_GB:-8} + STAMP=${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)} + OUT="$BACKUP_DIR/grafana/grafana-$STAMP.db" + + SSH_OPTS="-i /keys/id_ed25519 -o UserKnownHostsFile=/keys/known_hosts \ + -o StrictHostKeyChecking=yes -o BatchMode=yes -o ConnectTimeout=20 \ + -o ServerAliveInterval=30" + ssh_r() { ssh $SSH_OPTS "$BACKUP_HOST" "$@"; } + + echo "== target: $BACKUP_HOST:$BACKUP_DIR stamp=$STAMP" + ssh_r "mkdir -p '$BACKUP_DIR/grafana' '$BACKUP_DIR/manifests'" + avail_gb=$(ssh_r "df -Pk '$BACKUP_DIR' | awk 'NR==2{printf \"%d\", \$4/1048576}'") + avail_gb=${avail_gb:-0} + echo "== remote free space: ${avail_gb} GiB (minimum ${MIN_FREE_GB} GiB)" + if [ "$avail_gb" -lt "$MIN_FREE_GB" ]; then + echo "FAIL: not enough free space on $BACKUP_HOST" + exit 1 + fi + + echo "== sqlite snapshot of /grafana-data/grafana.db" + # The backup API takes a read transaction, so the copy is a consistent + # point-in-time image even while Grafana keeps writing. + python3 - <<'PY' + import sqlite3, sys + src = sqlite3.connect("/grafana-data/grafana.db", timeout=60) + src.execute("PRAGMA busy_timeout=60000") + dst = sqlite3.connect("/tmp/grafana.db") + src.backup(dst) + dst.close() + src.close() + check = sqlite3.connect("/tmp/grafana.db") + verdict = check.execute("PRAGMA integrity_check").fetchone()[0] + rows = {t: check.execute("SELECT count(*) FROM %s" % t).fetchone()[0] + for t in ("dashboard", "dashboard_version", "user", "alert_rule")} + check.close() + print(" integrity_check=%s dashboard=%s versions=%s user=%s alert_rule=%s" + % (verdict, rows["dashboard"], rows["dashboard_version"], + rows["user"], rows["alert_rule"])) + if verdict != "ok": + sys.exit("FAIL: sqlite integrity_check returned %r" % verdict) + PY + + local_sha=$(sha256sum /tmp/grafana.db | awk '{print $1}') + local_size=$(wc -c < /tmp/grafana.db) + echo "== shipping $local_size bytes sha256=$local_sha -> $OUT" + ssh_r "cat > '$OUT.part'" < /tmp/grafana.db + remote_sha=$(ssh_r "sha256sum '$OUT.part' | awk '{print \$1}'") + if [ "$local_sha" != "$remote_sha" ]; then + echo "FAIL: sha256 mismatch for $OUT (local=$local_sha remote=${remote_sha:-none})" + ssh_r "rm -f '$OUT.part'" + exit 1 + fi + ssh_r "mv '$OUT.part' '$OUT'" + rm -f /tmp/grafana.db + + echo "== manifest" + ssh_r "cd '$BACKUP_DIR' && { echo 'stamp $STAMP'; echo \"host \$(hostname -s)\"; \ + echo '--- grafana'; ls -l 'grafana/grafana-$STAMP.db'; \ + sha256sum 'grafana/grafana-$STAMP.db'; } >> manifests/$STAMP.txt && \ + tail -5 manifests/$STAMP.txt" + + echo "== retention: last $DB_KEEP grafana snapshots" + ssh_r "cd '$BACKUP_DIR/grafana' && ls -1t *.db 2>/dev/null | tail -n +$((DB_KEEP + 1)) | xargs -r rm -f" + ssh_r "df -h '$BACKUP_DIR' | tail -1" + + echo "RESULT=success stamp=$STAMP" +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: grafana-backup + namespace: monitoring + labels: + app: grafana-backup +spec: + # 23 minutes after the forgejo/cluster-backup job starts (02:37 UTC) so the + # two do not compete for WireGuard bandwidth or the Linode's disk. + schedule: "0 3 * * *" + timeZone: "Etc/UTC" + concurrencyPolicy: Forbid + startingDeadlineSeconds: 1800 + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + activeDeadlineSeconds: 900 + backoffLimit: 1 + template: + metadata: + labels: + app: grafana-backup + spec: + restartPolicy: Never + # The grafana PVC is local-path on siriussec; RWO still allows a + # second pod on the same node. + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: backup + # python3 alpine: the sqlite backup API is the only consistent + # way to copy a live database without a shell inside Grafana. + image: python:3.12-alpine + imagePullPolicy: IfNotPresent + command: ["/bin/sh", "/scripts/backup.sh"] + env: + - name: BACKUP_HOST + value: root@10.10.0.5 + - name: BACKUP_DIR + value: /root/cluster-backup + - name: DB_KEEP + value: "14" + volumeMounts: + - name: grafana-data + mountPath: /grafana-data + - name: keys + mountPath: /keys + readOnly: true + - name: scripts + mountPath: /scripts + readOnly: true + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + ephemeral-storage: 256Mi + memory: 256Mi + volumes: + - name: grafana-data + persistentVolumeClaim: + claimName: kube-prometheus-stack-grafana + - name: keys + secret: + # Copy of forgejo/cluster-backup-ssh, created out of band + # (never in git) — see docs/cluster-overview.md §8.1. + secretName: cluster-backup-ssh + defaultMode: 0400 + - name: scripts + configMap: + name: grafana-backup-scripts + defaultMode: 0755 diff --git a/monitoring/controllers/home/kustomization.yaml b/monitoring/controllers/home/kustomization.yaml index bb12166..0d2b035 100644 --- a/monitoring/controllers/home/kustomization.yaml +++ b/monitoring/controllers/home/kustomization.yaml @@ -9,6 +9,8 @@ resources: - gateway-probe.yaml - garage.yaml - prune-alerts.yaml + # Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users. + - grafana-backup.yaml - dashboards configMapGenerator: - name: kube-prometheus-stack-values From 953be9f3cf395ca256b48fde03ac89d608353b31 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 17:46:27 -0500 Subject: [PATCH 53/88] backup(portal): barman-cloud PITR via a Linode-side Garage WAL archive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sirius-growth/portal had a 24h-RPO pg_dump and no way to roll forward. This adds continuous WAL archiving + a daily base backup into a second, independent Garage node on the Linode (bucket pg-wal-archive, 10.10.0.5:3900, WireGuard-only), and proves a restore to a point in time end to end. - infrastructure/garage-linode/: podman+quadlet unit (the Linode is a kubelet node, no docker), garage.toml bound to 10.10.0.5 only, nft guard in PREROUTING -140, install.sh, README with the measured disk sizing, pitr-restore.md with the rehearsal transcript. - apps/base/sirius-growth/cluster.yaml: spec.backup.barmanObjectStore (destinationPath s3://pg-wal-archive, gzip WAL+data, retentionPolicy 14d), credentials from Secret sirius-growth/portal-wal-s3 (out of band, not in git). - apps/base/sirius-growth/scheduled-backup.yaml: ScheduledBackup portal-daily, 03:20 UTC, six-field cron. - docs/cluster-overview.md: §5.1 the WAL store, §8.1 coverage + sizing + gaps, §8.3 the PITR restore recipe. forgejo/pg is deliberately left on pg_dump only (a day of git history is annoying, not costly); portal keeps its nightly dump as the logical second copy. Rehearsed 2026-11-19: marker row at 22:35:06Z, unwanted row at 22:35:28Z, throwaway cluster restored to targetTime 22:35:15Z came back with the marker and without the later row. See infrastructure/garage-linode/pitr-restore.md. --- apps/base/sirius-growth/cluster.yaml | 46 +++++ apps/base/sirius-growth/kustomization.yaml | 1 + apps/base/sirius-growth/scheduled-backup.yaml | 19 ++ docs/cluster-overview.md | 182 +++++++++++++++++- infrastructure/garage-linode/README.md | 155 +++++++++++++++ infrastructure/garage-linode/garage.container | 38 ++++ infrastructure/garage-linode/garage.toml | 47 +++++ .../host/install-wal-archive-firewall.sh | 20 ++ .../host/wal-archive-firewall.nft | 41 ++++ .../host/wal-archive-firewall.service | 22 +++ infrastructure/garage-linode/install.sh | 60 ++++++ infrastructure/garage-linode/pitr-restore.md | 177 +++++++++++++++++ 12 files changed, 800 insertions(+), 8 deletions(-) create mode 100644 apps/base/sirius-growth/scheduled-backup.yaml create mode 100644 infrastructure/garage-linode/README.md create mode 100644 infrastructure/garage-linode/garage.container create mode 100644 infrastructure/garage-linode/garage.toml create mode 100755 infrastructure/garage-linode/host/install-wal-archive-firewall.sh create mode 100644 infrastructure/garage-linode/host/wal-archive-firewall.nft create mode 100644 infrastructure/garage-linode/host/wal-archive-firewall.service create mode 100755 infrastructure/garage-linode/install.sh create mode 100644 infrastructure/garage-linode/pitr-restore.md diff --git a/apps/base/sirius-growth/cluster.yaml b/apps/base/sirius-growth/cluster.yaml index aac5b9d..ead5986 100644 --- a/apps/base/sirius-growth/cluster.yaml +++ b/apps/base/sirius-growth/cluster.yaml @@ -24,6 +24,52 @@ spec: memory: 256Mi limits: memory: 1Gi + # --------------------------------------------------------------------------- + # Point-in-time recovery: continuous WAL archiving + daily base backups into + # Garage on the Linode hub (10.10.0.5), i.e. a different power and internet + # domain from this primary. Companion object: ScheduledBackup portal-daily. + # + # Credentials live in Secret sirius-growth/portal-wal-s3 (created out of band + # from the Garage key `cnpg-portal-wal`, id GK7f2b4bb1fc9abaec50fde37b, scope + # read+write on bucket `pg-wal-archive` only). Never commit the key values. + # + # This uses the operator's in-tree barman-cloud integration rather than the + # CNPG-I barman-cloud plugin: same barman-cloud binaries, no extra Deployment + # and TLS plugin registration to keep alive on a 3-node homelab. The plugin is + # the migration path when 1.30's in-tree support is finally removed. + # + # `pg_dump` in forgejo/cluster-backup still runs nightly for this database as + # a second, logical copy: a dump survives a barman-format regression or a + # store that has been emptied, and it is the only copy that is readable + # without barman. Belt and braces, not redundancy theatre — the RPO comes + # from the WAL archive, not from the dump. + backup: + retentionPolicy: "14d" + barmanObjectStore: + # Bucket root, not bucket/portal: barman appends the server name (which + # defaults to the Cluster name), so the archive lives at + # s3://pg-wal-archive/portal/{base,wals}/... — one prefix per cluster, + # which is what lets forgejo/pg share this bucket later without colliding. + destinationPath: s3://pg-wal-archive + endpointURL: http://10.10.0.5:3900 + s3Credentials: + accessKeyId: + name: portal-wal-s3 + key: ACCESS_KEY_ID + secretAccessKey: + name: portal-wal-s3 + key: ACCESS_SECRET_KEY + region: + name: portal-wal-s3 + key: REGION + # gzip on both: this is a WAL stream over the WireGuard mesh to a fixed + # 20 GB store, so bytes on the wire and in the bucket are the cost. + wal: + compression: gzip + maxParallel: 2 + data: + compression: gzip + jobs: 2 # Scraped via podmonitor.yaml in this directory (hand-written; see the comment # in apps/base/forgejo/podmonitor.yaml for why enablePodMonitor is false). # Only the operator's default query set here — this database needs no custom diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index 0719d16..cefdcec 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -15,6 +15,7 @@ resources: - service-portal-gate.yaml - httproute.yaml - cluster.yaml + - scheduled-backup.yaml - podmonitor.yaml - pvc-leadgen.yaml - cronjob-leadgen.yaml diff --git a/apps/base/sirius-growth/scheduled-backup.yaml b/apps/base/sirius-growth/scheduled-backup.yaml new file mode 100644 index 0000000..6f369ff --- /dev/null +++ b/apps/base/sirius-growth/scheduled-backup.yaml @@ -0,0 +1,19 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: portal-daily + namespace: sirius-growth +spec: + # Six-field cron (seconds first — CNPG, not standard cron). 03:20 UTC, clear + # of the 02:37 forgejo/cluster-backup CronJob so the two do not fight for the + # primary's I/O on a laptop disk. + schedule: "0 20 3 * * *" + cluster: + name: portal + # `self`: the Backup objects are owned by this ScheduledBackup, so deleting the + # schedule (or the namespace) does not leave orphaned Backups pointing at the + # cluster. Retention/cleanup of the archive itself is the Cluster's + # spec.backup.retentionPolicy (14d), enforced by barman-cloud on each backup. + backupOwnerReference: self + method: barmanObjectStore + immediate: false diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index 54823b8..6caac2c 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -311,6 +311,28 @@ Neither hostname is in the cloudflared ingress list, and `*.lab.internal` resolv **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. +### 5.1 A *second*, unrelated Garage node: the WAL archive on the Linode + +`infrastructure/garage-linode/` (not Flux-applied, like the Pi's) runs a +single-node Garage on the **Linode hub** and holds exactly one bucket, +`pg-wal-archive`, for CloudNativePG point-in-time recovery (§8.1, §8.3). + +| Property | Value | +|---|---| +| Where | Linode VPS (`linode` node), **podman** + quadlet `/etc/containers/systemd/garage.container` — there is no Docker on a kubelet node | +| Node | `994fd2f42ae72da6`, zone `dc1`, capacity **20 GB**, `replication_factor = 1` — a separate store with its own `node_key`, **not** a peer of the Pi's node | +| Endpoint | `http://10.10.0.5:3900` (S3) — the dummy-k8s WireGuard address, reachable from every pod over the mesh. `:3903` metrics, mesh-only, not scraped yet | +| Config | `garage.toml` binds those two addresses explicitly (no `0.0.0.0`), RPC secret from `/etc/garage/garage.env` (0600, not in git) | +| Firewall | nft `inet wal_archive_guard`, PREROUTING priority -140: accept `lo`/`wg0` (+ pod CIDR), drop everything else. ufw on this host is unrelated and stays as it is | +| State | `/var/lib/garage/{meta,data}`, covered by the nightly cluster-backup tree on the same host | +| Bucket | `pg-wal-archive` — private (`Website access: false`, anonymous GET → 403) | +| Keys | `cnpg-portal-wal` (`GK7f2b4bb1fc9abaec50fde37b`, RW on that bucket only) → Secret `sirius-growth/portal-wal-s3` | + +This node exists **because of where it is**, not because the estate needed a +second S3 service: a WAL archive on the Pi would sit in the same building, power +domain and uplink as the CNPG primary on siriussec. Off-site or it is not a +backup. + --- ## 6. Workloads @@ -492,11 +514,11 @@ StorageClass `local-path` (default, `WaitForFirstConsumer`, no expansion), provi **Dind growth hazard.** The amd64 runner's PVC is nominally 20 Gi and currently sits at **~22 G**: it has previously grown to ~50 GB from heavy Android/Rust builds and pushed the node into `DiskPressure`, which evicted the runner and left Forgejo and `pg-1` Pending. Docker image GC does not reclaim the data-root. Rule: when it approaches the cap, scale the runner to 0 **first**, then wipe `.../docker/*` (keeping `runner.ini` beside it), then scale back and re-pull the job image — wiping it under a live or restarting pod leaves `dockerd` half-initialised and every pull fails. Note the data-root also hosts the named volumes CI depends on (`cargo-target`, Android SDK, Gradle cache), so a wipe makes the next run fully cold. -Host disks *(live)*: siriussec `/` 214 G, 167 G used (**83 %**, 37 G free); rpi `/` 917 G, 506 G used (58 %, 374 G free); linode `/` 79 G, 11 G used (**14 %**, 64 G free — this is the backup target). +Host disks *(live)*: siriussec `/` 214 G, 167 G used (**83 %**, 37 G free); rpi `/` 917 G, 506 G used (58 %, 374 G free); linode `/` 79 G, 29 G used (**39 %**, 46 G free — this is the backup target, and since 2026-11-19 it also hosts the `pg-wal-archive` Garage node). ### 8.1 Backup coverage -Three independent scheduled paths, all **off** the T480 and **off** the Pi: +Five independent scheduled paths, all **off** the T480 and **off** the Pi: 1. **Cluster state → Linode VPS**, CronJob `forgejo/cluster-backup` (`apps/base/forgejo/cluster-backup.yaml`; exec-only RBAC in @@ -515,15 +537,24 @@ Three independent scheduled paths, all **off** the T480 and **off** the Pi: 3. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/` `garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) → `root@10.20.0.1:/root/garage-backup`. +4. **Point-in-time recovery for `sirius-growth/portal`**, continuous WAL archiving + + a daily base backup straight from the CNPG operator into a **second Garage + node running on the Linode** (`infrastructure/garage-linode/`, bucket + `pg-wal-archive`, bucket-private, `10.10.0.5:3900` WireGuard-only). This is the + only path with a **sub-24 h RPO**: recovery to any second inside the last 14 + days, not just "the state at 02:37". Config: + `apps/base/sirius-growth/cluster.yaml` `spec.backup.barmanObjectStore` + + `apps/base/sirius-growth/scheduled-backup.yaml` (`ScheduledBackup portal-daily`, + `20 3 * * *` UTC in **six**-field cron, seconds first). -A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` +A fifth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` `wireguard-backup.timer` (nightly 04:13) → `root@10.20.0.1:/root/pihost-backup`. | Artifact | Method | On the Linode | Retention | |---|---|---|---| | `forgejo-data` PVC (`/data`) | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `forgejo-data//` + `latest` symlink | 7 snapshots (hardlinked: 1 full copy + nightly deltas) | | `forgejo/pg` | `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket — no DB password exists in git or in the Job | `db/forgejo-pg-.dump` | 14 | -| `sirius-growth/portal` | same, through exec RBAC in `sirius-growth` | `db/sirius-growth-portal-.dump` | 14 | +| `sirius-growth/portal` | two independent copies, on purpose. **(a)** `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket, through exec RBAC in `sirius-growth` — logical, human-readable with any `pg_restore`. **(b)** barman-cloud **continuous WAL archive + daily base backup** (path 4) | (a) `db/sirius-growth-portal-.dump`; (b) `pg-wal-archive` bucket on the Linode: `portal/base//` + `portal/wals/…` | (a) 14 dumps; (b) 14 days of WAL (`retentionPolicy: 14d`) | | `osint/osint-db` (plain Postgres Deployment, has TimescaleDB + PostGIS) | `pg_dump -Fc -Z6` **inside the pod** over the local socket, using its own `POSTGRES_USER`/`POSTGRES_DB` via exec RBAC in `osint` | `db/osint-osint-db-.dump` | 14 | | `grafana.db` (sqlite) | **sqlite backup API** in a `python:3.12-alpine` pod that mounts the PVC — a `cp` of a live db can capture a torn page; the image is `-distroless`, so there is no shell to exec into | `grafana/grafana-.db` | 14 | | `sgs-leadgen-data` PVC | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `leadgen-data//` + `latest` | 7 | @@ -546,6 +577,44 @@ A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` - The Job lives in namespace `forgejo` (not a `backup` namespace) because a PVC cannot be mounted cross-namespace and `forgejo-data` is the largest artifact. +- **The WAL archive lives in a second Garage node on the Linode, and only there.** + Pointing barman at the Pi's Garage would put the archive in the same building, + power domain and uplink as the CNPG primary — a second copy of the same + failure. `infrastructure/garage-linode/` is a *separate* single-node store + (node `994fd2f42ae72da6`, capacity 20 GB, no relation to the Pi's + `d053db4dfc97bf78`): podman + a quadlet unit (this host has no Docker — it is a + kubelet node), `garage.toml` binding `10.10.0.5:3900`/`:3903` only, and an nft + table `inet wal_archive_guard` (PREROUTING -140) that drops 3900/3903 from + anything but `lo`/`wg0`. Measured off-mesh (from this laptop, straight to the + Linode's public IP, no VPN in the path): 3900 and 3903 **filtered**, and the + drop counter increments. Anonymous S3 GET on the bucket → **403 AccessDenied**. +- **Disk sizing for the WAL archive** *(measured 2026-11-19)*: Linode `/` is 79 G + with **46 G free**; Garage is capped at 20 GB. Actual usage after the first + base backup + 7 WAL segments: **4.9 MB** in 8 bucket objects (`data/` 9.3 MB + with Garage's block-store overhead, `meta/` 4.6 MB). `archive_timeout` is 5 min + and `wal_segment_size` 16 MB, so the archive takes at most 288 segments/day; + gzip turns a segment into 16–25 KB when the database is quiet (measured) → + ~6 MB WAL/day + a 4.5 MB base backup/day ≈ **150 MB for the whole 14-day + window**. Worst case on a busy database (every segment full at a typical 3–5× + gzip ratio) is ~1.5 GB/day → 21 GB for 14 days, i.e. it would hit the 20 GB + cap. The cap is deliberate: Garage answers `507 InsufficientStorage` and + `barman-cloud-backup` fails loudly (red `Backup`/`ScheduledBackup`) rather + than filling the Linode disk. If that ever fires, the lever is + `spec.backup.retentionPolicy` (7d) — not deleting WALs by hand. +- **The barman credentials are a namespaced Secret, not git**: + `sirius-growth/portal-wal-s3` (`ACCESS_KEY_ID` / `ACCESS_SECRET_KEY` / + `REGION`), created out of band from Garage key `cnpg-portal-wal` + (`GK7f2b4bb1fc9abaec50fde37b`, scope **read+write on `pg-wal-archive` only**, + no bucket-create). Recording key IDs is fine; the values are not in git, in the + docs, or in any comment. +- **CNPG 1.30 still ships the in-tree barman-cloud integration, and it warns that + 1.31 removes it** (`Warning: Native support for Barman Cloud backups and + recovery is deprecated ... Please migrate existing clusters to the new Barman + Cloud Plugin`). That is why this is on 1.30 only: the plugin (an extra + Deployment + CNPG-I registration + TLS) is the migration path, and it must land + before the operator goes to 1.31. Nothing else here changes when it does — the + bucket layout stays `portal/base` + `portal/wals`. + **Accepted gaps (with the reason, not just a TODO):** - **Prometheus TSDB** (2.4 GiB) — deliberately excluded: regenerated metrics @@ -561,10 +630,21 @@ A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` - **Pi `/etc/wireguard` is only as fresh as the last nightly run** — a peer added today is in the db and on the Pi, and reaches the Linode at 04:13. -A new CloudNativePG cluster is **not** picked up automatically: add -`/` to `CNPG_TARGETS` in the CronJob env *and* an equivalent -exec-only Role/RoleBinding for the `forgejo/cluster-backup` ServiceAccount in -that namespace. +**Closed 2026-11-19 — point-in-time recovery.** There is no longer a "restore to +02:37 or lose the day" gap: `sirius-growth/portal` can be recovered to any second +inside the 14-day window, and that restore has been rehearsed end to end (§8.3). +`forgejo/pg` is deliberately **not** on barman yet — a day of git history is +annoying, not costly, and one cluster proves the pattern; `osint/osint-db` is a +plain Deployment and cannot use CNPG backup at all. + +A new CloudNativePG cluster is **not** picked up automatically by either +mechanism. For dumps: add `/` to `CNPG_TARGETS` in the CronJob env +*and* an equivalent exec-only Role/RoleBinding for the `forgejo/cluster-backup` +ServiceAccount in that namespace. For barman: add `spec.backup.barmanObjectStore` +with a `destinationPath` of `s3://pg-wal-archive` (the bucket root — the server +name, defaulting to the cluster name, becomes the prefix, so clusters share one +bucket without colliding), the same `sirius-growth/portal-wal-s3`-shaped Secret +in that namespace, and a `ScheduledBackup`. ### 8.2 Restoring @@ -631,6 +711,92 @@ sudo systemctl start wg-quick@wg0 && sudo wg show ``` +### 8.3 Point-in-time recovery (`sirius-growth/portal`) + +Rehearsed end to end on **2026-11-19** (task `t_ce7d6772`) against the live +archive: a marker row was written, 10 s later a second, unwanted row was written, +and a throwaway cluster was restored with `targetTime` between the two. The +marker came back, the later row did not. + +**Step 1 — establish the target time.** Take it from the data, never from +memory: + +```bash +kubectl -n sirius-growth exec portal-1 -c postgres -- \ + psql -U postgres -d portal -tAc "select max(updated_at) from leads" # or pg_last_xact_replay_timestamp-style reasoning +date -u +%FT%TZ +``` + +**Step 2 — restore into a throwaway cluster.** Never into `portal` itself while +it is serving: CNPG recovery bootstraps a *new* data dir from the archive. + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: portal-pitr-test + namespace: sirius-growth +spec: + instances: 1 + imageName: ghcr.io/cloudnative-pg/postgresql:16 + storage: {size: 5Gi, storageClass: local-path} + affinity: {nodeSelector: {kubernetes.io/hostname: siriussec}} + bootstrap: + recovery: + source: portal-wal + recoveryTarget: + targetTime: "2026-11-19T22:35:15Z" # UTC, RFC3339 + externalClusters: + - name: portal-wal + barmanObjectStore: + destinationPath: s3://pg-wal-archive + endpointURL: http://10.10.0.5:3900 + serverName: portal # MUST be the *source* cluster name + s3Credentials: + accessKeyId: {name: portal-wal-s3, key: ACCESS_KEY_ID} + secretAccessKey: {name: portal-wal-s3, key: ACCESS_SECRET_KEY} + region: {name: portal-wal-s3, key: REGION} +``` + +```bash +kubectl apply -f portal-pitr-test.yaml +kubectl -n sirius-growth get cluster portal-pitr-test -w # Ready=True, "Cluster in healthy state" +``` + +**Step 3 — verify the cut, and then promote the result.** + +```bash +# the restore must stop before the unwanted transaction +kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \ + psql -U postgres -d portal -c "select id, note, at from order by id" +kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \ + psql -U postgres -tAc "select pg_is_in_recovery(), pg_last_xact_replay_timestamp()" +``` + +`pg_is_in_recovery() = f` on a single-instance recovery cluster means replay +finished and it has already been promoted. **A recovery cluster is writable the +moment it is Ready** — do not leave `portal-pitr-test` running, and do not point +application traffic at it. + +**Step 4 — make it the real one.** Two supported shapes: cut the app over to the +restored cluster (preferred — reversible), or re-point the PVC: + +```bash +# cut over: patch the API/portal Deployments' POSTGRES_HOST to portal-pitr-test-rw, +# then, once verified, keep it and delete the old cluster. +# in-place: let the recovery cluster finish, stop portal, and restore the portal-1 +# PVC from the test cluster's data dir — only after the app is confirmed correct. +``` + +**What recovery does not do:** it does not replay anything after the target, so +a "restore to now" is only as good as the last archived WAL. If +`pg_stat_archiver.failed_count` is non-zero, fix archiving *before* relying on a +timestamp near the present. + +**If the archive is lost or corrupt:** fall back to the nightly `pg_dump` +(§8.2 step 2) — 24 h RPO, logical, and readable without barman. That is exactly +why `sirius-growth/portal` stayed in `CNPG_TARGETS`. + --- ## 9. Known hazards and runbook pointers diff --git a/infrastructure/garage-linode/README.md b/infrastructure/garage-linode/README.md new file mode 100644 index 0000000..939625d --- /dev/null +++ b/infrastructure/garage-linode/README.md @@ -0,0 +1,155 @@ +# Garage on the Linode — the CloudNativePG WAL archive + +A **second, independent** single-node Garage on the Linode VPS. It holds one +bucket, `pg-wal-archive`, and its only consumer is CloudNativePG's barman-cloud +integration for `sirius-growth/portal` (continuous WAL archiving + daily base +backups → point-in-time recovery). + +It is **not** the Pi's Garage (`infrastructure/garage/`, node +`d053db4dfc97bf78`). Different host, different `node_key`, different metadata +dir, no RPC peering, nothing shared. That is the whole point: + +> The CNPG primary runs on `siriussec` in the same building, on the same power +> domain and the same uplink as the Pi. A WAL archive on the Pi would be a second +> copy of the same failure. The archive has to be off-site; the Linode is the +> only off-site box in this estate. + +## What runs + +| | | +|---|---| +| Host | Linode VPS, Kubernetes node `linode`, WireGuard `10.10.0.5` (`dummy-k8s`), hub `10.20.0.1` on `wg0` | +| Runtime | **podman 5.4** + a quadlet unit. This host is a kubelet node: installing `dockerd` next to the kubelet's containerd would add a second container runtime for no benefit, so the Pi's compose file cannot be reused verbatim | +| Unit | `/etc/containers/systemd/garage.container` → generated `garage.service` (`Restart=always`) | +| Image | `dxflrs/garage:v1.1.0` (same pinned tag as the Pi) | +| Config | `/etc/garage/garage.toml` (installed from this directory) | +| RPC secret | `/etc/garage/garage.env` → `GARAGE_RPC_SECRET`, `0600 root:root`, **not in git** | +| State | `/var/lib/garage/meta` (metadata, `node_key`) and `/var/lib/garage/data` (objects) | +| Node | `994fd2f42ae72da6`, zone `dc1`, capacity **20 GB**, `replication_factor = 1` | +| Bucket | `pg-wal-archive` — private, `Website access: false` | + +## Exposure — WireGuard only, twice + +1. `garage.toml` binds `10.10.0.5:3900` (S3) and `10.10.0.5:3903` (admin/metrics) + explicitly. There is no `0.0.0.0` listener and `eth0` (the public IP) is never + bound, so `ss -ltn` is proof by itself. +2. `host/wal-archive-firewall.nft` is an nftables table in **PREROUTING priority + -140** that accepts 3900/3903 only from `lo`/`wg0` (plus source + `10.244.0.0/16` for pods on this node) and **drops** everything else, with + counters on every rule. podman with `Network=host` does not need DNAT, but + the table keeps a future port mapping from reopening the path — and ufw alone + would not cover a container publish, exactly as on the Pi. + +Measured (2026-11-19), from the laptop **straight to the Linode's public IP with +no VPN in the path**: 3900 and 3903 both `filtered`, and +`nft list table inet wal_archive_guard` shows the drop counter incrementing. +Anonymous `GET http://10.10.0.5:3900/pg-wal-archive/` → **403 AccessDenied**. + +## Install / re-install + +```bash +# on the Linode, from a checkout of sirius/homek8s +cd infrastructure/garage-linode +sudo ./install.sh +``` + +`install.sh` is idempotent: it installs podman if missing, writes +`/etc/garage/{garage.toml,garage.env}` (generating the RPC secret once), installs +the quadlet unit and the nft guard **before** starting the container, then +assigns the layout capacity on first run (`layout assign -z dc1 -c 20G`) and +prints `garage status` + the listener set. + +Verify (all four must hold): + +```bash +systemctl status garage.service --no-pager | head -3 +ss -ltnH 'sport = :3900 or sport = :3903' # only 10.10.0.5, never 0.0.0.0 +podman exec garage /garage -c /etc/garage.toml status # node 994fd2f42ae72da6, HEALTHY +nft list table inet wal_archive_guard # counters on accept and drop +``` + +## Bucket and key + +```bash +G() { podman exec garage /garage -c /etc/garage.toml "$@"; } +G bucket create pg-wal-archive +G key create cnpg-portal-wal # prints the secret once — capture it +G bucket allow --read --write pg-wal-archive --key cnpg-portal-wal +G bucket info pg-wal-archive # Website access: false +``` + +Key ID `GK7f2b4bb1fc9abaec50fde37b` (`cnpg-portal-wal`), scope **read+write on +`pg-wal-archive` only** — no bucket-create, no other bucket, not an admin key. +The secret lives in the cluster as Secret `sirius-growth/portal-wal-s3` +(`ACCESS_KEY_ID`, `ACCESS_SECRET_KEY`, `REGION=garage`), created out of band and +**never committed**. Garage v1.1 has no `--yes` on `key create`; the secret is +printed exactly once, so redirect it to a `0600` root file and read it from there. + +## Disk sizing and retention + +Measured 2026-11-19: + +| | | +|---|---| +| Linode `/` | 79 GB, 29 GB used, **46 GB free** | +| Garage capacity | **20 GB** (layout), i.e. the store stops accepting before the disk does | +| First base backup + 7 WAL segments | **4.9 MB** in 8 bucket objects (`/var/lib/garage/data` 9.3 MB including Garage's block-store overhead, `meta` 4.6 MB) | +| `archive_timeout` / `wal_segment_size` on the primary | 5 min / 16 MB → at most 288 segments/day | +| Observed compressed segment | 16–25 KB when the portal is quiet | +| Steady state (quiet) | ~6 MB WAL/day + 4.5 MB base backup/day ≈ **150 MB per 14-day window** | +| Worst case (every segment full, 3–5× gzip) | ~1.5 GB/day ≈ 21 GB per 14 days — would hit the cap | + +Retention is `spec.backup.retentionPolicy: "14d"` on the Cluster, enforced by +barman-cloud when a backup completes. The 20 GB cap is deliberate: when it is +reached Garage returns `507 InsufficientStorage` and the `Backup` / +`ScheduledBackup` goes red — a visible failure instead of a full Linode disk. +The response to that is to lower the retention policy to `7d`, or to grow the +Linode disk; never to delete WALs by hand (that breaks the archive's +continuity and every PITR target that depends on the deleted segment). + +## How the archive is laid out + +`destinationPath: s3://pg-wal-archive` (bucket root) with the barman server name +defaulting to the cluster name, so: + +``` +pg-wal-archive/portal/base/20261119T223452/{backup.info,data.tar.gz} +pg-wal-archive/portal/wals/0000000100000000/00000001000000000000005A.gz +``` + +That is one prefix per cluster, which is what lets `forgejo/pg` share this bucket +later without colliding. Listing it (the postgres container has no credentials in +its own environment; the Secret does): + +```bash +kubectl -n sirius-growth run wal-list --rm -it --restart=Never \ + --image=public.ecr.aws/aws-cli/aws-cli:2.15.30 \ + --overrides='{"spec":{"containers":[{"name":"aws","image":"public.ecr.aws/aws-cli/aws-cli:2.15.30", + "envFrom":[{"secretRef":{"name":"portal-wal-s3"}}], + "command":["sh","-c","export AWS_ACCESS_KEY_ID=$ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=$ACCESS_SECRET_KEY AWS_DEFAULT_REGION=$REGION; aws --endpoint-url http://10.10.0.5:3900 s3 ls --recursive --human-readable s3://pg-wal-archive/"]}]}}' +``` + +## Restore + +Point-in-time recovery is a **cluster restore**, not a file copy. The full +rehearsed recipe (marker → restore to `targetTime` → verify) is §8.3 of +`docs/cluster-overview.md`; `pitr-restore.md` in this directory is the +self-contained version with the commands and the acceptance output. + +Short form: a throwaway `Cluster` with `bootstrap.recovery.source` pointing at an +`externalClusters` entry (`serverName: portal`, the same bucket and Secret) and +`recoveryTarget.targetTime`, then promote/cut over. Recovery needs the **base +backup** plus every WAL segment up to the target — one missing segment is a +failed restore, which is why the archive is never pruned by hand. + +## What this store is *not* + +- **Not a cluster peer of the Pi's Garage.** No `[rpc]` peering, no shared + `rpc_secret`, no replicated data. Two independent single-node stores. +- **Not Flux-managed.** Flux watches `./clusters/homek8s`; nothing there + references this directory. A push changes nothing on the Linode until + `install.sh` runs. +- **Not a general-purpose bucket host.** One bucket, one key, one consumer. Put + application media on the Pi's store; this one exists to be off-site. +- **Not exposed to the LAN or the internet**, and no Cloudflare tunnel, DNS + record or public bucket will be added to it. diff --git a/infrastructure/garage-linode/garage.container b/infrastructure/garage-linode/garage.container new file mode 100644 index 0000000..08435d3 --- /dev/null +++ b/infrastructure/garage-linode/garage.container @@ -0,0 +1,38 @@ +# Quadlet unit — Garage WAL archive on the Linode hub (10.10.0.5). +# +# Installed to /etc/containers/systemd/garage.container by install.sh; the +# podman systemd generator turns it into `garage.service` on the next +# `systemctl daemon-reload`. There is no docker on this host (it is a kubelet +# node — installing dockerd here would add a second container runtime next to +# the kubelet's containerd for no reason), so the Pi's compose file cannot be +# reused verbatim. Quadlet is the podman-native equivalent: one declarative +# file, systemd owns the lifecycle, no daemon of its own. +# +# Network=host on purpose: the container binds 10.10.0.5:3900 from garage.toml +# directly, so the published addresses are visible in `ss -lnt` on the host and +# no podman port-forwarding rules are injected into the node's netfilter state. + +[Unit] +Description=Garage S3 — CloudNativePG WAL archive (WireGuard-only) +Documentation=file:///etc/garage/README.md +After=network-online.target +Wants=network-online.target + +[Container] +ContainerName=garage +Image=docker.io/dxflrs/garage:v1.1.0 +Network=host +EnvironmentFile=/etc/garage/garage.env +Volume=/etc/garage/garage.toml:/etc/garage.toml:ro +Volume=/var/lib/garage/meta:/data/meta +Volume=/var/lib/garage/data:/data/data +Exec=/garage -c /etc/garage.toml server +LogDriver=journald + +[Service] +Restart=always +TimeoutStartSec=120 +TimeoutStopSec=60 + +[Install] +WantedBy=multi-user.target diff --git a/infrastructure/garage-linode/garage.toml b/infrastructure/garage-linode/garage.toml new file mode 100644 index 0000000..169602b --- /dev/null +++ b/infrastructure/garage-linode/garage.toml @@ -0,0 +1,47 @@ +# Garage v1.1.0 — WAL archive for CloudNativePG, on the Linode hub. +# +# Installed to /etc/garage/garage.toml (root:root 0644) by install.sh. +# +# This is a SECOND, independent Garage node — not a cluster peer of the Pi's +# node `d053db4dfc97bf78`. It exists because a WAL archive must live off-site: +# the Pi and the CNPG primary (siriussec) share a building, power domain and +# internet uplink, so archiving WALs there is a second copy of the same +# failure. Different node_key, different metadata dir, `replication_factor = 1`, +# nothing shared with the Pi's store. +# +# Listeners are bound to explicit addresses here AND the ports are guarded by +# host/wal-archive-firewall.nft before Docker-style DNAT could ever matter. +# `10.10.0.5` is the Linode worker's WireGuard-mesh InternalIP (dummy-k8s) — +# the only address any cluster pod can reach this on. eth0 (50.116.38.217) is +# not bound at all, so an off-mesh scan sees a filtered port, not a listener. +# +# rpc_secret is NOT in this file: GARAGE_RPC_SECRET comes from +# /etc/garage/garage.env (0600, out of git), same as the Pi's node. + +metadata_dir = "/data/meta" +data_dir = "/data/data" +db_engine = "sqlite" +replication_factor = 1 + +# Single node: nothing outside the container speaks RPC. Garage still needs the +# listener for its own CLI-over-loopback calls (`garage status`, `garage key`). +rpc_bind_addr = "127.0.0.1:3901" +rpc_public_addr = "127.0.0.1:3901" + +[s3_api] +s3_region = "garage" +# WireGuard address only. An empty/i.e. 0.0.0.0 bind here would put barman's +# archive on the Linode's public interface. +api_bind_addr = "10.10.0.5:3900" + +# Admin API + Prometheus metrics, mesh-only. No metrics_token: the port does not +# leave the WireGuard mesh. Add one here (and a bearer token in the scrape +# config) if 3903 is ever exposed beyond it. Not scraped today — the archive's +# growth is asserted from the filesystem in the backup README instead. +[admin] +api_bind_addr = "10.10.0.5:3903" + +# node_key is generated on first start and lives in metadata_dir (/data/meta). +# It is part of /root/garage-backup for the Pi's node; this node's meta/ is +# covered by the cluster-backup mirror on the same host. Restore meta/ before +# data/ or the layout no longer names this node and every bucket is orphaned. diff --git a/infrastructure/garage-linode/host/install-wal-archive-firewall.sh b/infrastructure/garage-linode/host/install-wal-archive-firewall.sh new file mode 100755 index 0000000..d21731c --- /dev/null +++ b/infrastructure/garage-linode/host/install-wal-archive-firewall.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Install the WAL-archive inbound guard on the Linode hub. Idempotent. +# +# sudo ./install-wal-archive-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/wal-archive-firewall.nft" /etc/nftables.d/wal_archive_guard.nft +install -D -m 0644 "$here/wal-archive-firewall.service" /etc/systemd/system/wal-archive-firewall.service + +systemctl daemon-reload +systemctl enable --now wal-archive-firewall.service + +nft list table inet wal_archive_guard >/dev/null +nft list table inet wal_archive_guard | grep -q 'dport { 3900, 3903 }' +echo "OK: wal_archive_guard loaded" +nft list table inet wal_archive_guard diff --git a/infrastructure/garage-linode/host/wal-archive-firewall.nft b/infrastructure/garage-linode/host/wal-archive-firewall.nft new file mode 100644 index 0000000..1bb10eb --- /dev/null +++ b/infrastructure/garage-linode/host/wal-archive-firewall.nft @@ -0,0 +1,41 @@ +#!/usr/sbin/nft -f +# WAL-archive inbound guard — defence in depth for Garage on the Linode hub. +# +# WHY THIS EXISTS AND WHY UFW ALONE IS NOT ENOUGH: +# On the Pi the risk is docker's DNAT bypassing ufw's INPUT chain. Here the +# store runs under podman with Network=host, so there is no DNAT to bypass — +# but the same rule shape is kept anyway, because the next person who adds a +# port mapping (or a second container that proxies this one) must not be able +# to reach 3900 from eth0 by accident. This table is evaluated in PREROUTING +# at priority -140, before any DNAT, so it binds the exposure to the transport +# rather than to how the listener was published. +# +# Effective policy for 3900 (S3 API) and 3903 (metrics/admin): +# accept from WireGuard (wg0) and loopback — incl. pod traffic arriving from +# the mesh with a 10.244.x source — drop everything else (eth0, LAN, public). +# DROP not REJECT: an off-mesh scan sees `filtered` and learns nothing. +# +# Note this is *in addition to* ufw, which on this host allows 22 from +# 10.20.0.0/24 and any from 10.10.0.0/24 / 10.244.0.0/16. ufw's own default is +# deny incoming, so the LAN path is already closed; this table keeps it closed +# even if someone later opens ufw wider for a different service. +# +# `destroy` (not `delete`) so re-running the unit replaces the table instead of +# appending a duplicate, and does not fail on first install. + +destroy table inet wal_archive_guard +table inet wal_archive_guard { + chain prerouting { + type filter hook prerouting priority -140; policy accept; + + # WireGuard mesh + hub link, and loopback (the garage CLI talks to + # 127.0.0.1:3901 inside this host namespace). + iifname { "lo", "wg0" } tcp dport { 3900, 3903 } counter accept + + # Pods on this node reach the dummy-k8s address from the pod network. + ip saddr 10.244.0.0/16 tcp dport { 3900, 3903 } counter accept + + # Everything else — eth0/public, any future interface nobody added above. + tcp dport { 3900, 3903 } counter drop + } +} diff --git a/infrastructure/garage-linode/host/wal-archive-firewall.service b/infrastructure/garage-linode/host/wal-archive-firewall.service new file mode 100644 index 0000000..938760e --- /dev/null +++ b/infrastructure/garage-linode/host/wal-archive-firewall.service @@ -0,0 +1,22 @@ +# /etc/systemd/system/wal-archive-firewall.service (linode) +# +# Host unit, installed by hand (not Flux-managed) — the file lives in git at +# infrastructure/garage-linode/host/. Same shape as garage-firewall.service on +# the Pi and k8s-api-firewall.service on siriussec. +# +# No Requires= on wg-quick@wg0: the tunnel is enabled at boot on this host but a +# hard dependency would turn a transient tunnel failure into "store unguarded +# and unit failed". The table only filters; it can load before the interface +# exists. +[Unit] +Description=Drop off-WireGuard inbound to the Garage WAL archive (3900/3903) +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/nft -f /etc/nftables.d/wal_archive_guard.nft +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/infrastructure/garage-linode/install.sh b/infrastructure/garage-linode/install.sh new file mode 100755 index 0000000..d22f189 --- /dev/null +++ b/infrastructure/garage-linode/install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Install the Garage WAL archive on the Linode hub (10.10.0.5). Idempotent. +# +# sudo ./install.sh +# +# Installs: podman (if missing), /etc/garage/{garage.toml,garage.env}, +# /etc/containers/systemd/garage.container, the nft guard, and the state dirs. +# Then starts the unit and assigns the node's layout capacity on first run. +# +# The RPC secret is generated once and never printed. Rewriting it on an +# existing install is harmless for a single-node store, but the copy in +# /root/garage-backup is what a rebuild should reuse. +set -euo pipefail + +here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) + +command -v podman >/dev/null || { + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq + apt-get install -y podman +} + +install -d -m 0755 /etc/garage /etc/containers/systemd /etc/nftables.d +install -d -m 0700 /var/lib/garage/meta /var/lib/garage/data + +install -m 0644 "$here/garage.toml" /etc/garage/garage.toml +install -m 0644 "$here/garage.container" /etc/containers/systemd/garage.container + +if [ ! -s /etc/garage/garage.env ]; then + umask 077 + printf 'GARAGE_RPC_SECRET=%s\n' "$(openssl rand -hex 32)" > /etc/garage/garage.env +fi +chmod 0600 /etc/garage/garage.env + +# Guard first: the listener must never exist unguarded, not even for the +# seconds between `compose/quadlet up` and a firewall install. +"$here/host/install-wal-archive-firewall.sh" >/dev/null + +systemctl daemon-reload +systemctl start garage.service + +# First run only: this Garage node needs a layout entry before it accepts +# writes. Capacity 20 GB against a 79 GB disk holding 29 GB of other data — +# see README "Disk sizing". +for _ in $(seq 1 30); do + garage_status=$(podman exec garage /garage -c /etc/garage.toml status 2>&1 || true) + grep -q 'NO ROLE' <<<"$garage_status" && break + sleep 2 +done + +if grep -q 'NO ROLE' <<<"$garage_status"; then + node_id=$(awk '/NO ROLE/{print $1}' <<<"$garage_status" | head -1) + podman exec garage /garage -c /etc/garage.toml layout assign -z dc1 -c 20G "$node_id" + podman exec garage /garage -c /etc/garage.toml layout apply --version 1 +fi + +# Verify rather than assume. +podman exec garage /garage -c /etc/garage.toml status +ss -ltnH 'sport = :3900 or sport = :3903' +nft list table inet wal_archive_guard >/dev/null && echo "OK: wal_archive_guard loaded" diff --git a/infrastructure/garage-linode/pitr-restore.md b/infrastructure/garage-linode/pitr-restore.md new file mode 100644 index 0000000..bdc1f6f --- /dev/null +++ b/infrastructure/garage-linode/pitr-restore.md @@ -0,0 +1,177 @@ +# Restore notes — point-in-time recovery for `sirius-growth/portal` + +Rehearsed end to end on **2026-11-19** (kanban task `t_ce7d6772`) against the live +archive. This file records the commands and the actual output of that rehearsal, +so the next person restores from a transcript instead of a hope. + +The archive: Garage on the Linode, bucket `pg-wal-archive`, `http://10.10.0.5:3900` +over the WireGuard mesh, credentials in Secret `sirius-growth/portal-wal-s3`. +Producer: `spec.backup.barmanObjectStore` on `Cluster sirius-growth/portal` +(WAL archiving continuous, `ScheduledBackup portal-daily` at 03:20 UTC, +`retentionPolicy: 14d`). + +## 0. Is the archive actually healthy? + +```bash +kubectl -n sirius-growth exec portal-1 -c postgres -- \ + psql -U postgres -tAc "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver" +# 00000001000000000000005B|2026-11-19 22:40:30.1+00|0 +``` + +`failed_count` must be 0 and `last_archived_time` must be minutes old. A +`targetTime` after the last archived WAL cannot be reached — recovery stops at +the last segment it can fetch. + +```bash +kubectl -n sirius-growth get backup -o wide # newest barmanObjectStore Backup: completed +kubectl -n sirius-growth get scheduledbackup # portal-daily, LAST BACKUP set +``` + +## 1. Prove the marker, then make the mistake + +The rehearsal wrote a marker, forced the WAL out, waited, then wrote a second +row that must *not* survive recovery: + +```bash +q() { kubectl -n sirius-growth exec portal-1 -c postgres -- psql -U postgres -d portal -tAc "$1"; } +q "insert into pitr_probe(note) values ('MARKER-before-target') returning id, at" +# 3|2026-11-19 22:35:06.127778+00 +q "select pg_switch_wal()" ; sleep 12 +q "select last_archived_wal, last_archived_time from pg_stat_archiver" +# 000000010000000000000059|2026-11-19 22:35:07.089783+00 +sleep 10 +q "insert into pitr_probe(note) values ('POISON-after-target') returning id, at" +# 4|2026-11-19 22:35:28.959782+00 +q "select pg_switch_wal()" ; sleep 12 +q "select last_archived_wal, last_archived_time from pg_stat_archiver" +# 00000001000000000000005A|2026-11-19 22:35:29.906592+00 +``` + +The target is therefore **`2026-11-19T22:35:15Z`** — 9 s after the marker, 14 s +before the row that must be lost. Note that WAL `…05A` (which contains the poison +row) *is* in the archive: the restore has to choose to stop, it is not starved of +data. + +## 2. Restore into a throwaway cluster + +Never restore over the live `portal` cluster while it is serving. + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: portal-pitr-test + namespace: sirius-growth + labels: {purpose: pitr-acceptance-test} +spec: + instances: 1 + imageName: ghcr.io/cloudnative-pg/postgresql:16 + storage: {size: 5Gi, storageClass: local-path} + affinity: {nodeSelector: {kubernetes.io/hostname: siriussec}} + resources: + requests: {cpu: 100m, memory: 256Mi} + limits: {memory: 1Gi} + bootstrap: + recovery: + source: portal-wal + recoveryTarget: + targetTime: "2026-11-19T22:35:15Z" + externalClusters: + - name: portal-wal + barmanObjectStore: + destinationPath: s3://pg-wal-archive + endpointURL: http://10.10.0.5:3900 + serverName: portal # MUST match the source Cluster name + s3Credentials: + accessKeyId: {name: portal-wal-s3, key: ACCESS_KEY_ID} + secretAccessKey: {name: portal-wal-s3, key: ACCESS_SECRET_KEY} + region: {name: portal-wal-s3, key: REGION} +``` + +`serverName` is not optional: it is the barman prefix (`portal/base`, +`portal/wals`). Omit it and the restore cluster looks for its own name and finds +an empty history. `targetTime` is UTC RFC3339 — a wrong timezone silently +restores the wrong hour. + +The operator restores the base backup, replays WAL, stops at the target and +promotes: + +``` +ready=False phase=Setting up primary +ready=False phase=Waiting for the instances to become active +ready=True phase=Cluster in healthy state +portal-pitr-test 1 1 Cluster in healthy state portal-pitr-test-1 +``` + +## 3. The acceptance evidence + +``` +$ kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \ + psql -U postgres -d portal -c "select id, note, at from pitr_probe order by id" + id | note | at +----+----------------------+------------------------------- + 3 | MARKER-before-target | 2026-11-19 22:35:06.127778+00 +(1 row) + +$ ... -tAc "select count(*) from pitr_probe where note like 'POISON%'" +0 +``` + +Marker present, post-target row gone. The rest of the database came back with it +(physical restore, all databases, no `pg_restore` ordering games), e.g. +`clients 4 = 4`, `calendar_tokens 3 = 3`, `applications 1 = 1` against the +primary at that moment. + +``` +$ ... -tAc "select pg_is_in_recovery()" +f # replay finished, instance promoted +``` + +`pg_is_in_recovery() = f` is expected here and is **not** a failure: a CNPG +recovery cluster with `instances: 1` promotes itself once it hits the target. It +is writable from that moment — which is why the test cluster must be deleted, and +why nothing may point application traffic at it before you decide to. + +```bash +kubectl -n sirius-growth delete cluster portal-pitr-test +``` + +## 4. Making the restored data the real data + +Two shapes, both legitimate: + +1. **Cut over (preferred, reversible).** Point the app at + `portal-pitr-test-rw` (`POSTGRES_HOST` in the API/portal Deployments — through + git, not `kubectl set env`), verify, then drop the old cluster only after the + app has been confirmed on the restored copy. +2. **In place.** Keep `portal`, stop its instances, and swap the PVC content from + the recovered data directory. Slower, destructive, and easy to get wrong — + only with the app scaled to zero. + +Either way, take a fresh base backup once the decision is made +(`kubectl apply` a `Backup` CR against the surviving cluster) so the archive has +a post-recovery base rather than one from before the incident. + +## Gotchas that cost time + +- **Flux owns `apps/base/sirius-growth/cluster.yaml`.** A hand `kubectl apply` of + a new `spec.backup` is reverted by the `apps` Kustomization within its 1 min + interval. Config changes belong in the branch/PR. (During the rehearsal the + `kustomize-controller` Deployment was scaled to 0 for the test window and + scaled back afterwards; `Backup`/`Cluster` objects created by hand are not in + the Kustomization inventory, so they are not pruned.) +- **`ScheduledBackup.spec.schedule` is six-field cron, seconds first.** `0 20 3 + * * *` = 03:20:00 UTC. Copying a five-field crontab string silently means + "every minute" in the first field. +- **The bucket prefix is `portal/portal/…` only if you get `destinationPath` + wrong.** Use `s3://pg-wal-archive` for the bucket root; barman appends the + server name. +- **CNPG 1.30 warns that in-tree barman-cloud is removed in 1.31.** If that + upgrade happens, migrate to the Barman Cloud Plugin first; until then the + archives remain readable by `barman-cloud-restore` in the same container image. +- **If archiving has failed** (`pg_stat_archiver.failed_count > 0`), fix it and + let a fresh base backup complete before trusting any recent `targetTime`. +- **Fallback when the archive is unusable:** the nightly `pg_dump` in + `forgejo/cluster-backup` (`db/sirius-growth-portal-.dump`, 14 retained, + §8.2 step 2 of `docs/cluster-overview.md`). 24 h RPO, logical, independent of + barman and of the Linode Garage node. From f3a8233e3766e7427695488f378902fda627f35f Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 19 Nov 2026 17:55:49 -0500 Subject: [PATCH 54/88] controllers(cert-manager): install cert-manager 1.21.3 for the CNPG-I barman plugin The Barman Cloud plugin release manifest ships an Issuer plus two Certificate objects (operator->plugin mTLS) and assumes cert-manager is present. Installing it as a HelmRelease off charts.jetstack.io with crds.enabled=true, in its own Flux Kustomization so the databases Kustomization can wait on it. No new cert is issued by this commit; the plugin (next change) is the only consumer. --- clusters/homek8s/cert-manager.yaml | 18 ++++++ .../cert-manager/kustomization.yaml | 7 ++ .../controllers/cert-manager/namespace.yaml | 4 ++ .../controllers/cert-manager/release.yaml | 64 +++++++++++++++++++ .../controllers/cert-manager/repository.yaml | 8 +++ 5 files changed, 101 insertions(+) create mode 100644 clusters/homek8s/cert-manager.yaml create mode 100644 infrastructure/controllers/cert-manager/kustomization.yaml create mode 100644 infrastructure/controllers/cert-manager/namespace.yaml create mode 100644 infrastructure/controllers/cert-manager/release.yaml create mode 100644 infrastructure/controllers/cert-manager/repository.yaml diff --git a/clusters/homek8s/cert-manager.yaml b/clusters/homek8s/cert-manager.yaml new file mode 100644 index 0000000..e32ba2a --- /dev/null +++ b/clusters/homek8s/cert-manager.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cert-manager + namespace: flux-system +spec: + interval: 10m0s + retryInterval: 1m + timeout: 5m + sourceRef: + kind: GitRepository + name: flux-system + path: ./infrastructure/controllers/cert-manager + # The HelmRelease owns the chart; pruning the Kustomization deletes the + # release object, and the chart's CRDs carry `helm.sh/resource-policy: keep` + # so they survive. Nothing here is a bare CRD in git, hence prune: true. + prune: true + wait: true diff --git a/infrastructure/controllers/cert-manager/kustomization.yaml b/infrastructure/controllers/cert-manager/kustomization.yaml new file mode 100644 index 0000000..77c66d9 --- /dev/null +++ b/infrastructure/controllers/cert-manager/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: cert-manager +resources: + - namespace.yaml + - repository.yaml + - release.yaml diff --git a/infrastructure/controllers/cert-manager/namespace.yaml b/infrastructure/controllers/cert-manager/namespace.yaml new file mode 100644 index 0000000..c90416f --- /dev/null +++ b/infrastructure/controllers/cert-manager/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: cert-manager diff --git a/infrastructure/controllers/cert-manager/release.yaml b/infrastructure/controllers/cert-manager/release.yaml new file mode 100644 index 0000000..a58ae37 --- /dev/null +++ b/infrastructure/controllers/cert-manager/release.yaml @@ -0,0 +1,64 @@ +# cert-manager — installed for one reason: the Barman Cloud CNPG-I plugin +# expects its operator/plugin mTLS pair as cert-manager `Certificate` objects +# (the upstream v0.16.0 manifest ships an Issuer + two Certificates and assumes +# cert-manager is present). CNPG-I *can* run on hand-made cert bundles, but that +# would put a CA private key in a hand-maintained Secret with no renewal; the +# chart is the supported path and is ~3 small pods. +# +# CRDs: `crds.enabled: true` is required — `Certificate`/`Issuer` do not exist +# otherwise. The chart annotates its CRDs with `helm.sh/resource-policy: keep`, +# so uninstalling the release does not delete issued certs' CRDs out from under +# the running plugin. Do not add `crds.keep: false`. +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: cert-manager + namespace: cert-manager +spec: + releaseName: cert-manager + interval: 15m + chart: + spec: + chart: cert-manager + version: "v1.21.3" + sourceRef: + kind: HelmRepository + name: jetstack + namespace: cert-manager + install: + crds: CreateReplace + remediation: + retries: 3 + upgrade: + crds: CreateReplace + remediation: + retries: 3 + values: + crds: + enabled: true + # Homelab sizing: upstream requests are already small, but the webhook and + # cainjector each get a memory ceiling so a runaway cannot evict the CNPG + # primary that shares this node. + resources: + requests: + cpu: 10m + memory: 64Mi + limits: + memory: 192Mi + webhook: + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + memory: 128Mi + cainjector: + resources: + requests: + cpu: 10m + memory: 64Mi + limits: + memory: 192Mi + # No Prometheus Operator CRs here (ServiceMonitor is not installed). + prometheus: + enabled: false diff --git a/infrastructure/controllers/cert-manager/repository.yaml b/infrastructure/controllers/cert-manager/repository.yaml new file mode 100644 index 0000000..2fad310 --- /dev/null +++ b/infrastructure/controllers/cert-manager/repository.yaml @@ -0,0 +1,8 @@ +apiVersion: source.toolkit.fluxcd.io/v1 +kind: HelmRepository +metadata: + name: jetstack + namespace: cert-manager +spec: + interval: 24h + url: https://charts.jetstack.io/ From c45255242bbe19fd387c47be779b59d82ec525bf Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 19 Nov 2026 17:58:12 -0500 Subject: [PATCH 55/88] db(portal): migrate WAL archiving to the CNPG-I Barman Cloud plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CloudNativePG 1.30 deprecates spec.backup.barmanObjectStore and 1.31 removes it, so the pin on 1.30.0 was a hard gate. This closes that gate: - Vendors plugin-barman-cloud v0.16.0 verbatim into infrastructure/databases/base/upstream/ (the operator manifest's pattern), with a kustomize patch only for --log-level=info and resource bounds. v0.16.0 requires CNPG >= 1.30 and is registered through Service annotations; its operator<->plugin mTLS pair comes from cert-manager (previous commit). - Adds ObjectStore sirius-growth/portal-wal: the literal translation of the retired barmanObjectStore block, with retentionPolicy 14d moved off the Cluster (in the plugin, retention belongs to the store). - Cluster portal drops spec.backup entirely and gains spec.plugins (barman-cloud.cloudnative-pg.io, isWALArchiver, barmanObjectName portal-wal, serverName portal). The server name is the barman prefix, so the plugin keeps writing s3://pg-wal-archive/portal/{base,wals}/... — the same objects the in-tree archiver left behind; the 14-day window stays readable. - ScheduledBackup portal-daily switches to method: plugin. - databases waits on cert-manager; apps waits on databases (the ObjectStore CRD ships with the plugin). - CNPG dashboard: the backup timestamp metric family changes name under the plugin, so the panel now accepts both. --- apps/base/sirius-growth/cluster.yaml | 52 +- apps/base/sirius-growth/kustomization.yaml | 2 + .../sirius-growth/objectstore-portal-wal.yaml | 51 + apps/base/sirius-growth/scheduled-backup.yaml | 11 +- clusters/homek8s/apps.yaml | 4 + clusters/homek8s/databases.yaml | 10 +- .../databases/base/kustomization.yaml | 14 +- .../databases/base/patch-barman-cloud.yaml | 36 + .../upstream/plugin-barman-cloud-0.16.0.yaml | 1157 +++++++++++++++++ .../controllers/home/dashboards/build.py | 16 +- .../home/dashboards/cnpg-postgres.yaml | 10 +- 11 files changed, 1312 insertions(+), 51 deletions(-) create mode 100644 apps/base/sirius-growth/objectstore-portal-wal.yaml create mode 100644 infrastructure/databases/base/patch-barman-cloud.yaml create mode 100644 infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml diff --git a/apps/base/sirius-growth/cluster.yaml b/apps/base/sirius-growth/cluster.yaml index ead5986..09e5d4a 100644 --- a/apps/base/sirius-growth/cluster.yaml +++ b/apps/base/sirius-growth/cluster.yaml @@ -27,49 +27,35 @@ spec: # --------------------------------------------------------------------------- # Point-in-time recovery: continuous WAL archiving + daily base backups into # Garage on the Linode hub (10.10.0.5), i.e. a different power and internet - # domain from this primary. Companion object: ScheduledBackup portal-daily. + # domain from this primary. Companion objects: ObjectStore portal-wal (the + # store + 14d retention) and ScheduledBackup portal-daily. + # + # This is the CNPG-I Barman Cloud **plugin** (Deployment cnpg-system/barman-cloud, + # vendored in infrastructure/databases/base), not the operator's in-tree + # barman-cloud support: 1.30 deprecates the in-tree path and 1.31 removes it + # (`Warning: Native support for Barman Cloud backups and recovery is + # deprecated ...`). See objectstore-portal-wal.yaml for the store definition. + # + # `serverName: portal` is the barman prefix and must stay exactly the cluster + # name: the plugin writes to s3://pg-wal-archive/portal/{base,wals}/... — the + # same objects the in-tree archiver left behind, so the existing 14-day window + # stays restorable. Changing it starts a new prefix and abandons that window. # # Credentials live in Secret sirius-growth/portal-wal-s3 (created out of band # from the Garage key `cnpg-portal-wal`, id GK7f2b4bb1fc9abaec50fde37b, scope # read+write on bucket `pg-wal-archive` only). Never commit the key values. # - # This uses the operator's in-tree barman-cloud integration rather than the - # CNPG-I barman-cloud plugin: same barman-cloud binaries, no extra Deployment - # and TLS plugin registration to keep alive on a 3-node homelab. The plugin is - # the migration path when 1.30's in-tree support is finally removed. - # # `pg_dump` in forgejo/cluster-backup still runs nightly for this database as # a second, logical copy: a dump survives a barman-format regression or a # store that has been emptied, and it is the only copy that is readable # without barman. Belt and braces, not redundancy theatre — the RPO comes # from the WAL archive, not from the dump. - backup: - retentionPolicy: "14d" - barmanObjectStore: - # Bucket root, not bucket/portal: barman appends the server name (which - # defaults to the Cluster name), so the archive lives at - # s3://pg-wal-archive/portal/{base,wals}/... — one prefix per cluster, - # which is what lets forgejo/pg share this bucket later without colliding. - destinationPath: s3://pg-wal-archive - endpointURL: http://10.10.0.5:3900 - s3Credentials: - accessKeyId: - name: portal-wal-s3 - key: ACCESS_KEY_ID - secretAccessKey: - name: portal-wal-s3 - key: ACCESS_SECRET_KEY - region: - name: portal-wal-s3 - key: REGION - # gzip on both: this is a WAL stream over the WireGuard mesh to a fixed - # 20 GB store, so bytes on the wire and in the bucket are the cost. - wal: - compression: gzip - maxParallel: 2 - data: - compression: gzip - jobs: 2 + plugins: + - name: barman-cloud.cloudnative-pg.io + isWALArchiver: true + parameters: + barmanObjectName: portal-wal + serverName: portal # Scraped via podmonitor.yaml in this directory (hand-written; see the comment # in apps/base/forgejo/podmonitor.yaml for why enablePodMonitor is false). # Only the operator's default query set here — this database needs no custom diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index cefdcec..17365df 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -14,6 +14,8 @@ resources: - service-blog.yaml - service-portal-gate.yaml - httproute.yaml + # The WAL archive store must exist before the Cluster references it. + - objectstore-portal-wal.yaml - cluster.yaml - scheduled-backup.yaml - podmonitor.yaml diff --git a/apps/base/sirius-growth/objectstore-portal-wal.yaml b/apps/base/sirius-growth/objectstore-portal-wal.yaml new file mode 100644 index 0000000..90a82d3 --- /dev/null +++ b/apps/base/sirius-growth/objectstore-portal-wal.yaml @@ -0,0 +1,51 @@ +# The WAL archive for Cluster sirius-growth/portal, in the CNPG-I Barman Cloud +# plugin's own CR instead of Cluster.spec.backup.barmanObjectStore. +# +# Same store, same layout: destinationPath is the *bucket root* and the plugin +# appends the server name (Cluster.spec.plugins[].parameters.serverName, set to +# `portal`), so the existing objects stay exactly where the in-tree archiver put +# them — s3://pg-wal-archive/portal/{base,wals}/... . Anything that changes the +# prefix silently abandons the 14-day window that is already in the bucket. +# +# `spec.configuration` is the literal translation of the retired +# `spec.backup.barmanObjectStore` block (same schema, same Secret), and +# `retentionPolicy` moved here from Cluster.spec.backup.retentionPolicy — in the +# plugin architecture retention is a property of the store, not the cluster. +# +# Credentials: Secret sirius-growth/portal-wal-s3 (Garage key `cnpg-portal-wal`, +# id GK7f2b4bb1fc9abaec50fde37b, RW on bucket `pg-wal-archive` only), created +# out of band. The key values are deliberately not in git. +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: portal-wal + namespace: sirius-growth +spec: + configuration: + destinationPath: s3://pg-wal-archive + endpointURL: http://10.10.0.5:3900 + s3Credentials: + accessKeyId: + name: portal-wal-s3 + key: ACCESS_KEY_ID + secretAccessKey: + name: portal-wal-s3 + key: ACCESS_SECRET_KEY + region: + name: portal-wal-s3 + key: REGION + # gzip on both directions: this is a WAL stream over the WireGuard mesh into + # a 20 GB store on the Linode, so bytes on the wire and in the bucket are + # the cost. Must match what the in-tree archiver wrote (gzip) — the + # archive is read by segment, but a mismatch in base-backup compression + # would make the existing base backups unrestorable. + wal: + compression: gzip + maxParallel: 2 + data: + compression: gzip + jobs: 2 + # Enforced by the plugin instance sidecar every 30 min (default + # retentionPolicyIntervalSeconds) with barman-cloud's retention logic, i.e. + # the same 14-day window the in-tree archiver maintained. + retentionPolicy: "14d" diff --git a/apps/base/sirius-growth/scheduled-backup.yaml b/apps/base/sirius-growth/scheduled-backup.yaml index 6f369ff..3aa68d1 100644 --- a/apps/base/sirius-growth/scheduled-backup.yaml +++ b/apps/base/sirius-growth/scheduled-backup.yaml @@ -12,8 +12,13 @@ spec: name: portal # `self`: the Backup objects are owned by this ScheduledBackup, so deleting the # schedule (or the namespace) does not leave orphaned Backups pointing at the - # cluster. Retention/cleanup of the archive itself is the Cluster's - # spec.backup.retentionPolicy (14d), enforced by barman-cloud on each backup. + # cluster. Retention/cleanup of the archive itself is the ObjectStore's + # spec.retentionPolicy (14d), enforced by the plugin's sidecar. backupOwnerReference: self - method: barmanObjectStore + # Plugin method, not `barmanObjectStore`: the in-tree method is removed in + # CNPG 1.31. `pluginConfiguration` names the CNPG-I plugin, whose + # ObjectStore is referenced by the Cluster's spec.plugins. + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io immediate: false diff --git a/clusters/homek8s/apps.yaml b/clusters/homek8s/apps.yaml index eee63cd..a060326 100644 --- a/clusters/homek8s/apps.yaml +++ b/clusters/homek8s/apps.yaml @@ -15,3 +15,7 @@ spec: prune: true dependsOn: - name: infrastructure + # `sirius-growth` now carries an `ObjectStore` (barmancloud.cnpg.io) whose + # CRD ships with the plugin in the `databases` Kustomization, and the + # portal Cluster references it. Apply apps only after that CRD exists. + - name: databases diff --git a/clusters/homek8s/databases.yaml b/clusters/homek8s/databases.yaml index ddf15c2..108270d 100644 --- a/clusters/homek8s/databases.yaml +++ b/clusters/homek8s/databases.yaml @@ -11,9 +11,15 @@ spec: kind: GitRepository name: flux-system path: ./infrastructure/databases/base - # The CloudNativePG operator bundle contains its 11 CRDs. Those must never be - # pruned automatically: dropping them would delete every Cluster/Database + # The CloudNativePG operator bundle contains its 11 CRDs, and the vendored + # Barman Cloud plugin adds the `ObjectStore` CRD. Those must never be pruned + # automatically: dropping them would delete every Cluster/Database/Backup # object (and the Forgejo and portal Postgres clusters with them). Same # reasoning as gateway-api-crds. Reverting the operator Deployment args is a # git change, not a prune. prune: false + # The plugin's operator<->plugin mTLS pair is issued by cert-manager + # (Issuer/Certificate in the vendored plugin manifest). Applying those before + # the cert-manager CRDs and webhook exist just churns; wait for it. + dependsOn: + - name: cert-manager diff --git a/infrastructure/databases/base/kustomization.yaml b/infrastructure/databases/base/kustomization.yaml index d1e6e52..89db5d0 100644 --- a/infrastructure/databases/base/kustomization.yaml +++ b/infrastructure/databases/base/kustomization.yaml @@ -1,4 +1,4 @@ -# CloudNativePG operator, pinned at 1.30.0. +# CloudNativePG operator, pinned at 1.30.0, plus the CNPG-I Barman Cloud plugin. # # The operator was installed by hand at some point and Flux did not own it, so # a kubectl patch was lost on every reinstall. The upstream release manifest is @@ -7,9 +7,21 @@ # and patched only for the deltas that already existed live plus the widened # leader-election window. Do not upgrade the version in this directory without # a separate, tested change: the CRDs are in this bundle. +# +# The Barman Cloud plugin is the replacement for the in-tree barman-cloud +# integration that 1.30 still ships but deprecates (removed in 1.31). Also +# vendored verbatim (sha256 +# aee614683892dd4b44ff9f7afaca55254f1c28de17abbaa0552bf2e1228f7155, +# https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v0.16.0/manifest.yaml): +# a separate Deployment in cnpg-system, registered with the operator through +# Service annotations, carrying the `ObjectStore` CRD (barmancloud.cnpg.io). Its +# operator<->plugin mTLS pair is issued by cert-manager (Flux Kustomization +# `cert-manager`). v0.16.0 requires CloudNativePG >= 1.30 — satisfied above. apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - upstream/cnpg-1.30.0.yaml + - upstream/plugin-barman-cloud-0.16.0.yaml patches: - path: patch-controller-manager.yaml + - path: patch-barman-cloud.yaml diff --git a/infrastructure/databases/base/patch-barman-cloud.yaml b/infrastructure/databases/base/patch-barman-cloud.yaml new file mode 100644 index 0000000..7b4cb19 --- /dev/null +++ b/infrastructure/databases/base/patch-barman-cloud.yaml @@ -0,0 +1,36 @@ +# Delta on the vendored Barman Cloud plugin manifest (0.16.0). +# +# Upstream ships the plugin operator with `--log-level=debug`. On this cluster +# nothing scrapes the plugin's logs and siriussec's root filesystem is the +# tightest disk in the estate, so the arg is lowered to `info`. Everything else +# in the release manifest is used verbatim — including the Service annotations +# (`cnpg.io/pluginName`, `cnpg.io/pluginPort`, `cnpg.io/pluginClientSecret`, +# `cnpg.io/pluginServerSecret`) that are the actual CNPG-I registration. +# +# The whole `args` list is restated because strategic merge replaces a container +# `args` list rather than merging it. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: barman-cloud + namespace: cnpg-system +spec: + template: + spec: + containers: + - name: barman-cloud + args: + - operator + - --server-cert=/server/tls.crt + - --server-key=/server/tls.key + - --client-cert=/client/tls.crt + - --server-address=:9090 + - --leader-elect + - --log-level=info + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + cpu: 500m + memory: 256Mi diff --git a/infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml b/infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml new file mode 100644 index 0000000..707fa7f --- /dev/null +++ b/infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml @@ -0,0 +1,1157 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.23.0 + name: objectstores.barmancloud.cnpg.io +spec: + group: barmancloud.cnpg.io + names: + kind: ObjectStore + listKind: ObjectStoreList + plural: objectstores + singular: objectstore + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: ObjectStore is the Schema for the objectstores API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: |- + Specification of the desired behavior of the ObjectStore. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + properties: + configuration: + description: The configuration for the barman-cloud tool suite + properties: + azureCredentials: + description: The credentials to use to upload data to Azure Blob + Storage + properties: + connectionString: + description: The connection string to be used + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + inheritFromAzureAD: + description: Use the Azure AD based authentication without + providing explicitly the keys. + type: boolean + storageAccount: + description: The storage account where to upload data + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + storageKey: + description: |- + The storage account key to be used in conjunction + with the storage account name + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + storageSasToken: + description: |- + A shared-access-signature to be used in conjunction with + the storage account name + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + useDefaultAzureCredentials: + description: |- + Use the default Azure authentication flow, which includes DefaultAzureCredential. + This allows authentication using environment variables and managed identities. + type: boolean + type: object + data: + description: |- + The configuration to be used to backup the data files + When not defined, base backups files will be stored uncompressed and may + be unencrypted in the object store, according to the bucket default + policy. + properties: + additionalCommandArgs: + description: |- + AdditionalCommandArgs represents additional arguments that can be appended + to the 'barman-cloud-backup' command-line invocation. These arguments + provide flexibility to customize the backup process further according to + specific requirements or configurations. + + Example: + In a scenario where specialized backup options are required, such as setting + a specific timeout or defining custom behavior, users can use this field + to specify additional command arguments. + + Note: + It's essential to ensure that the provided arguments are valid and supported + by the 'barman-cloud-backup' command, to avoid potential errors or unintended + behavior during execution. + items: + type: string + type: array + compression: + description: |- + Compress a backup file (a tar file per tablespace) while streaming it + to the object store. Available options are empty string (no + compression, default), `gzip`, `bzip2`, `lz4`, `snappy`, and `zstd`. + enum: + - bzip2 + - gzip + - lz4 + - snappy + - zstd + type: string + encryption: + description: |- + Whenever to force the encryption of files (if the bucket is + not already configured for that). + Allowed options are empty string (use the bucket policy, default), + `AES256` and `aws:kms` + enum: + - AES256 + - aws:kms + type: string + immediateCheckpoint: + description: |- + Control whether the I/O workload for the backup initial checkpoint will + be limited, according to the `checkpoint_completion_target` setting on + the PostgreSQL server. If set to true, an immediate checkpoint will be + used, meaning PostgreSQL will complete the checkpoint as soon as + possible. `false` by default. + type: boolean + jobs: + description: |- + The number of parallel jobs to be used to upload the backup, defaults + to 2 + format: int32 + minimum: 1 + type: integer + restoreAdditionalCommandArgs: + description: |- + Additional arguments that can be appended to the 'barman-cloud-restore' + command-line invocation. These arguments provide flexibility to customize + the data restore process further, according to specific requirements or + configurations. + + Example: + In a scenario where specialized restore options are required, such as setting + a specific read timeout or defining custom behavior, users can use this field + to specify additional command arguments. + + Note: + It's essential to ensure that the provided arguments are valid and supported + by the 'barman-cloud-restore' command, to avoid potential errors or unintended + behavior during execution. + items: + type: string + type: array + type: object + destinationPath: + description: |- + The path where to store the backup (i.e. s3://bucket/path/to/folder) + this path, with different destination folders, will be used for WALs + and for data + minLength: 1 + type: string + endpointCA: + description: |- + EndpointCA store the CA bundle of the barman endpoint. + Useful when using self-signed certificates to avoid + errors with certificate issuer and barman-cloud-wal-archive + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + endpointURL: + description: |- + Endpoint to be used to upload data to the cloud, + overriding the automatic endpoint discovery + type: string + googleCredentials: + description: The credentials to use to upload data to Google Cloud + Storage + properties: + applicationCredentials: + description: The secret containing the Google Cloud Storage + JSON file with the credentials + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + gkeEnvironment: + description: |- + If set to true, will presume that it's running inside a GKE environment, + default to false. + type: boolean + type: object + historyTags: + additionalProperties: + type: string + description: |- + HistoryTags is a list of key value pairs that will be passed to the + Barman --history-tags option. + type: object + s3AddressingStyle: + description: |- + How bucket names appear in S3 requests: `virtual` (bucket.endpoint/key), + `path` (endpoint/bucket/key) or `auto` (boto3 decides, same as unset). + Requires s3Credentials and Barman 3.18 or later. + enum: + - auto + - virtual + - path + type: string + s3Credentials: + description: The credentials to use to upload data to S3 + properties: + accessKeyId: + description: The reference to the access key id + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + inheritFromIAMRole: + description: Use the role based authentication without providing + explicitly the keys. + type: boolean + region: + description: The reference to the secret containing the region + name + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + secretAccessKey: + description: The reference to the secret access key + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + sessionToken: + description: The references to the session key + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + sseCustomerKey: + description: |- + Reference to the secret holding the key for Server-Side Encryption with + Customer-provided keys (SSE-C): a base64-encoded 256-bit AES key. + barman-cloud uses it to encrypt the objects it uploads and to read them + back. Meant for S3-compatible providers that only support SSE-C + (e.g. Hetzner Object Storage). Cannot be combined with `encryption`. + Works with any authentication method. Changing the key makes the + existing objects unreadable: use a new `destinationPath` or `serverName`. + properties: + key: + description: The key to select + type: string + name: + description: Name of the referent. + type: string + required: + - key + - name + type: object + type: object + serverName: + description: |- + The server name on S3, the cluster name is used if this + parameter is omitted + type: string + tags: + additionalProperties: + type: string + description: |- + Tags is a list of key value pairs that will be passed to the + Barman --tags option. + type: object + wal: + description: |- + The configuration for the backup of the WAL stream. + When not defined, WAL files will be stored uncompressed and may be + unencrypted in the object store, according to the bucket default policy. + properties: + archiveAdditionalCommandArgs: + description: |- + Additional arguments that can be appended to the 'barman-cloud-wal-archive' + command-line invocation. These arguments provide flexibility to customize + the WAL archive process further, according to specific requirements or configurations. + + Example: + In a scenario where specialized backup options are required, such as setting + a specific timeout or defining custom behavior, users can use this field + to specify additional command arguments. + + Note: + It's essential to ensure that the provided arguments are valid and supported + by the 'barman-cloud-wal-archive' command, to avoid potential errors or unintended + behavior during execution. + items: + type: string + type: array + compression: + description: |- + Compress a WAL file before sending it to the object store. Available + options are empty string (no compression, default), `gzip`, `bzip2`, + `lz4`, `snappy`, `xz`, and `zstd`. + enum: + - bzip2 + - gzip + - lz4 + - snappy + - xz + - zstd + type: string + encryption: + description: |- + Whenever to force the encryption of files (if the bucket is + not already configured for that). + Allowed options are empty string (use the bucket policy, default), + `AES256` and `aws:kms` + enum: + - AES256 + - aws:kms + type: string + maxParallel: + description: |- + Number of WAL files to be either archived in parallel (when the + PostgreSQL instance is archiving to a backup object store) or + restored in parallel (when a PostgreSQL standby is fetching WAL + files from a recovery object store). If not specified, WAL files + will be processed one at a time. It accepts a positive integer as a + value - with 1 being the minimum accepted value. + minimum: 1 + type: integer + restoreAdditionalCommandArgs: + description: |- + Additional arguments that can be appended to the 'barman-cloud-wal-restore' + command-line invocation. These arguments provide flexibility to customize + the WAL restore process further, according to specific requirements or configurations. + + Example: + In a scenario where specialized backup options are required, such as setting + a specific timeout or defining custom behavior, users can use this field + to specify additional command arguments. + + Note: + It's essential to ensure that the provided arguments are valid and supported + by the 'barman-cloud-wal-restore' command, to avoid potential errors or unintended + behavior during execution. + items: + type: string + type: array + type: object + required: + - destinationPath + type: object + x-kubernetes-validations: + - fieldPath: .serverName + message: use the 'serverName' plugin parameter in the Cluster resource + reason: FieldValueForbidden + rule: '!has(self.serverName)' + - fieldPath: .data.encryption + message: cannot be used together with s3Credentials.sseCustomerKey + reason: FieldValueForbidden + rule: '!has(self.s3Credentials) || !has(self.s3Credentials.sseCustomerKey) + || !has(self.data) || !has(self.data.encryption)' + - fieldPath: .wal.encryption + message: cannot be used together with s3Credentials.sseCustomerKey + reason: FieldValueForbidden + rule: '!has(self.s3Credentials) || !has(self.s3Credentials.sseCustomerKey) + || !has(self.wal) || !has(self.wal.encryption)' + - fieldPath: .s3AddressingStyle + message: s3AddressingStyle requires s3Credentials + reason: FieldValueForbidden + rule: '!has(self.s3AddressingStyle) || has(self.s3Credentials)' + instanceSidecarConfiguration: + description: The configuration for the sidecar that runs in the instance + pods + properties: + additionalContainerArgs: + description: |- + AdditionalContainerArgs is an optional list of command-line arguments + to be passed to the sidecar container when it starts. + The provided arguments are appended to the container’s default arguments. + items: + type: string + type: array + x-kubernetes-validations: + - message: do not set --log-level in additionalContainerArgs; + use spec.instanceSidecarConfiguration.logLevel + reason: FieldValueForbidden + rule: '!self.exists(a, a.startsWith(''--log-level''))' + env: + description: The environment to be explicitly passed to the sidecar + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: |- + Name of the environment variable. + May consist of any printable ASCII characters except '='. + type: string + value: + description: |- + Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in the container and + any service environment variables. If a variable cannot be resolved, + the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless of whether the variable + exists or not. + Defaults to "". + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: |- + The key to select from the ConfigMap's Data field. + Keys in the BinaryData field are not currently propagated to container env vars. + type: string + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: |- + Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + fileKeyRef: + description: |- + FileKeyRef selects a key of the env file. + Requires the EnvFiles feature gate to be enabled. + properties: + key: + description: |- + The key within the env file. An invalid key will prevent the pod from starting. + The keys defined within a source may consist of any printable ASCII characters except '='. + During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters. + type: string + optional: + default: false + description: |- + Specify whether the file or its key must be defined. If the file or key + does not exist, then the env var is not published. + If optional is set to true and the specified key does not exist, + the environment variable will not be set in the Pod's containers. + + If optional is set to false and the specified key does not exist, + an error will be returned during Pod creation. + type: boolean + path: + description: |- + The path within the volume from which to select the file. + Must be relative and may not contain the '..' path or start with '..'. + type: string + volumeName: + description: The name of the volume mount containing + the env file. + type: string + required: + - key + - path + - volumeName + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: |- + Selects a resource of the container: only resources limits and requests + (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + logLevel: + default: info + description: 'The log level for PostgreSQL instances. Valid values + are: `error`, `warning`, `info` (default), `debug`, `trace`' + enum: + - error + - warning + - info + - debug + - trace + type: string + resources: + description: Resources define cpu/memory requests and limits for + the sidecar that runs in the instance pods. + properties: + claims: + description: |- + Claims lists the names of resources, defined in spec.resourceClaims, + that are used by this container. + + This field depends on the + DynamicResourceAllocation feature gate. + + This field is immutable. It can only be set for containers. + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: |- + Name must match the name of one entry in pod.spec.resourceClaims of + the Pod where this field is used. It makes that resource available + inside a container. + type: string + request: + description: |- + Request is the name chosen for a request in the referenced claim. + If empty, everything from the claim is made available, otherwise + only the result of this request. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Limits describes the maximum amount of compute resources allowed. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Requests describes the minimum amount of compute resources required. + If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + otherwise to an implementation-defined value. Requests cannot exceed Limits. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + type: object + retentionPolicyIntervalSeconds: + default: 1800 + description: |- + The retentionCheckInterval defines the frequency at which the + system checks and enforces retention policies. + type: integer + type: object + retentionPolicy: + description: |- + RetentionPolicy is the retention policy to be used for backups + and WALs (i.e. '60d'). The retention policy is expressed in the form + of `XXu` where `XX` is a positive integer and `u` is in `[dwm]` - + days, weeks, months. + pattern: ^[1-9][0-9]*[dwm]$ + type: string + required: + - configuration + type: object + status: + description: |- + Most recently observed status of the ObjectStore. This data may not be up to + date. Populated by the system. Read-only. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + properties: + serverRecoveryWindow: + additionalProperties: + description: |- + RecoveryWindow represents the time span between the first + recoverability point and the last successful backup of a PostgreSQL + server, defining the period during which data can be restored. + properties: + firstRecoverabilityPoint: + description: |- + The first recoverability point in a PostgreSQL server refers to + the earliest point in time to which the database can be + restored. + format: date-time + type: string + lastFailedBackupTime: + description: The last failed backup time + format: date-time + type: string + lastSuccessfulBackupTime: + description: The last successful backup time + format: date-time + type: string + type: object + description: ServerRecoveryWindow maps each server to its recovery + window + type: object + type: object + required: + - metadata + - spec + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: plugin-barman-cloud + name: plugin-barman-cloud + namespace: cnpg-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: plugin-barman-cloud + name: barman-plugin-leader-election-role + namespace: cnpg-system +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: barman-plugin-metrics-auth-role +rules: +- apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: barman-plugin-metrics-reader +rules: +- nonResourceURLs: + - /metrics + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: plugin-barman-cloud + name: barman-plugin-objectstore-editor-role +rules: +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores/status + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: plugin-barman-cloud + name: barman-plugin-objectstore-viewer-role +rules: +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores + verbs: + - get + - list + - watch +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores/status + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: plugin-barman-cloud +rules: +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - delete + - get + - list + - watch +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores/finalizers + verbs: + - update +- apiGroups: + - barmancloud.cnpg.io + resources: + - objectstores/status + verbs: + - get + - patch + - update +- apiGroups: + - postgresql.cnpg.io + resources: + - backups + verbs: + - get + - list + - watch +- apiGroups: + - postgresql.cnpg.io + resources: + - clusters/finalizers + verbs: + - update +- apiGroups: + - rbac.authorization.k8s.io + resources: + - rolebindings + - roles + verbs: + - create + - get + - list + - patch + - update + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: plugin-barman-cloud + name: barman-plugin-leader-election-rolebinding + namespace: cnpg-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: barman-plugin-leader-election-role +subjects: +- kind: ServiceAccount + name: plugin-barman-cloud + namespace: cnpg-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: barman-plugin-metrics-auth-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: barman-plugin-metrics-auth-role +subjects: +- kind: ServiceAccount + name: plugin-barman-cloud + namespace: cnpg-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: plugin-barman-cloud + name: plugin-barman-cloud-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: plugin-barman-cloud +subjects: +- kind: ServiceAccount + name: plugin-barman-cloud + namespace: cnpg-system +--- +apiVersion: v1 +data: + SIDECAR_IMAGE: | + Z2hjci5pby9jbG91ZG5hdGl2ZS1wZy9wbHVnaW4tYmFybWFuLWNsb3VkLXNpZGVjYXI6dj + AuMTYuMA== +kind: Secret +metadata: + name: plugin-barman-cloud-5kkd8f288d + namespace: cnpg-system +type: Opaque +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + cnpg.io/pluginClientSecret: barman-cloud-client-tls + cnpg.io/pluginPort: "9090" + cnpg.io/pluginServerSecret: barman-cloud-server-tls + labels: + app: barman-cloud + cnpg.io/pluginName: barman-cloud.cloudnative-pg.io + name: barman-cloud + namespace: cnpg-system +spec: + ports: + - port: 9090 + protocol: TCP + targetPort: 9090 + selector: + app: barman-cloud +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: barman-cloud + name: barman-cloud + namespace: cnpg-system +spec: + replicas: 1 + selector: + matchLabels: + app: barman-cloud + strategy: + type: Recreate + template: + metadata: + labels: + app: barman-cloud + spec: + containers: + - args: + - operator + - --server-cert=/server/tls.crt + - --server-key=/server/tls.key + - --client-cert=/client/tls.crt + - --server-address=:9090 + - --leader-elect + - --log-level=debug + env: + - name: SIDECAR_IMAGE + valueFrom: + secretKeyRef: + key: SIDECAR_IMAGE + name: plugin-barman-cloud-5kkd8f288d + image: ghcr.io/cloudnative-pg/plugin-barman-cloud:v0.16.0 + name: barman-cloud + ports: + - containerPort: 9090 + protocol: TCP + readinessProbe: + initialDelaySeconds: 10 + periodSeconds: 10 + tcpSocket: + port: 9090 + resources: {} + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsGroup: 10001 + runAsUser: 10001 + seccompProfile: + type: RuntimeDefault + volumeMounts: + - mountPath: /server + name: server + - mountPath: /client + name: client + securityContext: + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault + serviceAccountName: plugin-barman-cloud + volumes: + - name: server + secret: + secretName: barman-cloud-server-tls + - name: client + secret: + secretName: barman-cloud-client-tls +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: barman-cloud-client + namespace: cnpg-system +spec: + commonName: barman-cloud-client + duration: 2160h + isCA: false + issuerRef: + group: cert-manager.io + kind: Issuer + name: selfsigned-issuer + renewBefore: 360h + secretName: barman-cloud-client-tls + usages: + - client auth +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: barman-cloud-server + namespace: cnpg-system +spec: + commonName: barman-cloud + dnsNames: + - barman-cloud + duration: 2160h + isCA: false + issuerRef: + group: cert-manager.io + kind: Issuer + name: selfsigned-issuer + renewBefore: 360h + secretName: barman-cloud-server-tls + usages: + - server auth +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: selfsigned-issuer + namespace: cnpg-system +spec: + selfSigned: {} diff --git a/monitoring/controllers/home/dashboards/build.py b/monitoring/controllers/home/dashboards/build.py index 91ec779..88868d0 100644 --- a/monitoring/controllers/home/dashboards/build.py +++ b/monitoring/controllers/home/dashboards/build.py @@ -245,9 +245,9 @@ cnpg = [ {"h": 5, "w": 4, "x": 16, "y": 1}, desc="1 = the operator is asking for a manual switchover (e.g. after a fencing event).", thresholds=[{"color": "green", "value": None}, {"color": "red", "value": 1}]), - stat("Last available backup", [target('max by (namespace) (cnpg_collector_last_available_backup_timestamp{%s})' % CLUSTER_NS)], + stat("Last available backup", [target('max by (namespace) (cnpg_collector_last_available_backup_timestamp{%s} or barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{%s})' % (CLUSTER_NS, CLUSTER_NS))], {"h": 5, "w": 4, "x": 20, "y": 1}, unit="dateTimeAsIso", - desc="0 = never. There are NO Backup/Cluster backup resources in this cluster (verified: `kubectl get backups.postgresql.cnpg.io -A` is empty), so a 0 here is the honest answer, not a broken panel.", + desc="0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, which exposes its own metric family `barman_cloud_cloudnative_pg_io_*`; the in-tree `cnpg_collector_*` name is kept in the `or` for any cluster still on the deprecated path. A 0 means neither series exists.", thresholds=[{"color": "red", "value": None}, {"color": "green", "value": 1}]), row("Throughput", 6), @@ -280,10 +280,10 @@ cnpg = [ desc="pg_database_size. Both PVs are 10Gi (forgejo/pg) and 5Gi (sirius-growth/portal) — this is the trend that fills them."), ts("WAL generation", [target('sum by (namespace) (rate(cnpg_collector_wal_bytes{%s}[5m]))' % CLUSTER_NS, "{{namespace}}")], {"h": 8, "w": 8, "x": 8, "y": 25}, unit="Bps", - desc="Bytes of WAL written per second. On a cluster with no backups, WAL has nothing archiving it away."), + desc="Bytes of WAL written per second. sirius-growth/portal archives its WAL to the Linode Garage; forgejo/pg does not archive, so its WAL only ever fills the pg_wal directory."), ts("WAL archiver failures", [target('max by (namespace) (cnpg_pg_stat_archiver_failed_count{%s})' % CLUSTER_NS, "{{namespace}}")], {"h": 8, "w": 8, "x": 16, "y": 25}, unit="short", - desc="pg_stat_archiver.failed_count. Archiving is not configured on either cluster (no ObjectStore/backup), so treat non-zero here as 'something was attempted and failed'."), + desc="pg_stat_archiver.failed_count. Archiving is configured only on sirius-growth/portal (Barman Cloud plugin -> Linode Garage); forgejo/pg has no archiver, so any non-zero value is the honest signal that WAL failed to reach the archive."), row("Replication (single instance — panels are honest about it)", 33), ts("Replication lag", [target('max by (namespace) (cnpg_pg_replication_lag{%s})' % CLUSTER_NS, "{{namespace}}")], @@ -294,9 +294,11 @@ cnpg = [ {"h": 6, "w": 8, "x": 8, "y": 34}, unit="short", desc="Both clusters run instances: 1, so 0 streaming replicas and in_recovery=0 is the correct reading. A future replica would light these up with no dashboard change."), note("Known unknowns on the CNPG board", """\ -- **No backups exist.** `kubectl get backups.postgresql.cnpg.io -A` returns nothing; neither Cluster - declares `spec.backup`. The "Last available backup" stat therefore reads 0 (never) — that is the - real state, not a missing metric. +- **Backups exist on one cluster only.** `sirius-growth/portal` archives WAL + daily base backups + through the CNPG-I Barman Cloud plugin (`ObjectStore portal-wal`) into the Linode Garage; + `forgejo/pg` has no archiver by design. The "Last available backup" stat reads 0 only if neither + the plugin's `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` nor the legacy + `cnpg_collector_last_available_backup_timestamp` series exists. - **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas / in recovery are structurally zero. The panels show the zero and say so instead of hiding them. - **Query age vs transaction age.** CNPG's default query set exposes diff --git a/monitoring/controllers/home/dashboards/cnpg-postgres.yaml b/monitoring/controllers/home/dashboards/cnpg-postgres.yaml index 80e8c57..56c7895 100644 --- a/monitoring/controllers/home/dashboards/cnpg-postgres.yaml +++ b/monitoring/controllers/home/dashboards/cnpg-postgres.yaml @@ -423,7 +423,7 @@ data: "id": 29, "type": "stat", "title": "Last available backup", - "description": "0 = never. There are NO Backup/Cluster backup resources in this cluster (verified: `kubectl get backups.postgresql.cnpg.io -A` is empty), so a 0 here is the honest answer, not a broken panel.", + "description": "0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, which exposes its own metric family `barman_cloud_cloudnative_pg_io_*`; the in-tree `cnpg_collector_*` name is kept in the `or` for any cluster still on the deprecated path. A 0 means neither series exists.", "datasource": { "type": "prometheus", "uid": "prometheus" @@ -440,7 +440,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max by (namespace) (cnpg_collector_last_available_backup_timestamp{namespace=~\"$namespace\"})", + "expr": "max by (namespace) (cnpg_collector_last_available_backup_timestamp{namespace=~\"$namespace\"} or barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{namespace=~\"$namespace\"})", "refId": "A", "editorMode": "code", "range": true, @@ -937,7 +937,7 @@ data: "id": 40, "type": "timeseries", "title": "WAL generation", - "description": "Bytes of WAL written per second. On a cluster with no backups, WAL has nothing archiving it away.", + "description": "Bytes of WAL written per second. sirius-growth/portal archives its WAL to the Linode Garage; forgejo/pg does not archive, so its WAL only ever fills the pg_wal directory.", "datasource": { "type": "prometheus", "uid": "prometheus" @@ -994,7 +994,7 @@ data: "id": 41, "type": "timeseries", "title": "WAL archiver failures", - "description": "pg_stat_archiver.failed_count. Archiving is not configured on either cluster (no ObjectStore/backup), so treat non-zero here as 'something was attempted and failed'.", + "description": "pg_stat_archiver.failed_count. Archiving is configured only on sirius-growth/portal (Barman Cloud plugin -> Linode Garage); forgejo/pg has no archiver, so any non-zero value is the honest signal that WAL failed to reach the archive.", "datasource": { "type": "prometheus", "uid": "prometheus" @@ -1203,7 +1203,7 @@ data: "showLineNumbers": false, "showMiniMap": false }, - "content": "- **No backups exist.** `kubectl get backups.postgresql.cnpg.io -A` returns nothing; neither Cluster\n declares `spec.backup`. The \"Last available backup\" stat therefore reads 0 (never) \u2014 that is the\n real state, not a missing metric.\n- **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas /\n in recovery are structurally zero. The panels show the zero and say so instead of hiding them.\n- **Query age vs transaction age.** CNPG's default query set exposes\n `cnpg_backends_max_tx_duration_seconds` (transaction age). Per-statement `query_start` age is not in\n the default set; adding it would need another custom query in the cluster's\n `customQueriesConfigMap`.\n- **Permissions.** Custom queries run as `cnpg_metrics_exporter`, not superuser. See\n docs/monitoring-dashboards.md for the GRANT the Forgejo Actions metrics need.\n" + "content": "- **Backups exist on one cluster only.** `sirius-growth/portal` archives WAL + daily base backups\n through the CNPG-I Barman Cloud plugin (`ObjectStore portal-wal`) into the Linode Garage;\n `forgejo/pg` has no archiver by design. The \"Last available backup\" stat reads 0 only if neither\n the plugin's `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` nor the legacy\n `cnpg_collector_last_available_backup_timestamp` series exists.\n- **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas /\n in recovery are structurally zero. The panels show the zero and say so instead of hiding them.\n- **Query age vs transaction age.** CNPG's default query set exposes\n `cnpg_backends_max_tx_duration_seconds` (transaction age). Per-statement `query_start` age is not in\n the default set; adding it would need another custom query in the cluster's\n `customQueriesConfigMap`.\n- **Permissions.** Custom queries run as `cnpg_metrics_exporter`, not superuser. See\n docs/monitoring-dashboards.md for the GRANT the Forgejo Actions metrics need.\n" } } ] From 4c90eba08b3a6f92045d433fa7d45ba0e4859cc3 Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 19 Nov 2026 18:09:23 -0500 Subject: [PATCH 56/88] =?UTF-8?q?docs(pitr):=20the=20plugin=20path=20is=20?= =?UTF-8?q?real=20=E2=80=94=20transcript,=20layout,=20metrics,=201.31=20ga?= =?UTF-8?q?te=20closed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Documents what the live migration actually produced (kanban t_5df331de): - §8.3: restore manifest is externalClusters[].plugin + barmanObjectName/ serverName, with the 2026-11-19 rehearsal transcript (marker 23:04:53.07, target 23:05:00Z, poison 23:05:15.80 -> marker present, poison gone). - §8.4 (new): how the plugin is wired — vendored manifest, Service-annotation registration, cert-manager dependency, ObjectStore/ScheduledBackup shape, the injected init-sidecar, and the metrics family change. - §8.1/§5.1: producer is the plugin; retention moved to the ObjectStore; the "1.31 is a hard gate" caveat is replaced by "gate closed". - §9/§10 + namespace table: cert-manager and barman-cloud are live state now, with the verification log rows. - pitr-restore.md rewritten for the plugin (manifest, sidecar log evidence, the two-servers-name trap, retention location). - CNPG dashboard: the `or` now prefers the plugin's metric — the legacy cnpg_collector series still holds the PRE-migration timestamp. --- docs/cluster-overview.md | 160 +++++++++++++----- infrastructure/garage-linode/README.md | 14 +- infrastructure/garage-linode/pitr-restore.md | 147 +++++++++------- .../controllers/home/dashboards/build.py | 4 +- .../home/dashboards/cnpg-postgres.yaml | 4 +- 5 files changed, 224 insertions(+), 105 deletions(-) diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index 6caac2c..7881d65 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -333,6 +333,12 @@ second S3 service: a WAL archive on the Pi would sit in the same building, power domain and uplink as the CNPG primary on siriussec. Off-site or it is not a backup. +Producer: the **CNPG-I Barman Cloud plugin** (`cnpg-system/barman-cloud`, +`ObjectStore sirius-growth/portal-wal`) — not the operator's deprecated in-tree +`barmanObjectStore`. The bucket, key and layout are unchanged (`portal/base/…`, +`portal/wals/…`), because the plugin appends the same barman server name +(`portal`) to the same `s3://pg-wal-archive` root. See §8.4. + --- ## 6. Workloads @@ -388,9 +394,10 @@ Nothing runs on `linode` except its Cilium agent. `rpi` runs only the two runner | `kube-system` | 45 d | control plane, Cilium, Envoy, CoreDNS, hubble-relay + hubble-ui | | `kube-public`, `kube-node-lease`, `default` | 45 d | kubeadm defaults | | `forgejo` | 45 d | Forgejo, its CNPG cluster, 3 runners, prune CronJob | -| `cnpg-system` | 45 d | CloudNativePG operator | +| `cnpg-system` | 45 d | CloudNativePG operator **+ the CNPG-I Barman Cloud plugin** (`barman-cloud`, §8.4) | +| `cert-manager` | 1 m | cert-manager v1.21.3 (controller + webhook + cainjector) — installed for the Barman Cloud plugin's mTLS pair, §8.4 | | `monitoring` | 1 d | kube-prometheus-stack: Prometheus (7d/8GB), Grafana, kube-state-metrics, node-exporter | -| `flux-system` | 41 d | 4 Flux controllers, GitRepository, 4 Kustomizations | +| `flux-system` | 41 d | 4 Flux controllers, GitRepository, 7 Kustomizations (`flux-system`, `gateway-api-crds`, `cert-manager`, `databases`, `infrastructure`, `monitoring`, `apps`) | | `gateway-system` | 45 d | Gateway `public` | | `internal` | 41 d | Gateways `internal` (8081) and `hubble-ui` (8084) | | `local-path-storage` | 45 d | provisioner | @@ -538,14 +545,18 @@ Five independent scheduled paths, all **off** the T480 and **off** the Pi: `garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) → `root@10.20.0.1:/root/garage-backup`. 4. **Point-in-time recovery for `sirius-growth/portal`**, continuous WAL archiving - + a daily base backup straight from the CNPG operator into a **second Garage - node running on the Linode** (`infrastructure/garage-linode/`, bucket - `pg-wal-archive`, bucket-private, `10.10.0.5:3900` WireGuard-only). This is the - only path with a **sub-24 h RPO**: recovery to any second inside the last 14 - days, not just "the state at 02:37". Config: - `apps/base/sirius-growth/cluster.yaml` `spec.backup.barmanObjectStore` + - `apps/base/sirius-growth/scheduled-backup.yaml` (`ScheduledBackup portal-daily`, - `20 3 * * *` UTC in **six**-field cron, seconds first). + + a daily base backup straight from the **CNPG-I Barman Cloud plugin** into a + **second Garage node running on the Linode** (`infrastructure/garage-linode/`, + bucket `pg-wal-archive`, bucket-private, `10.10.0.5:3900` WireGuard-only). This + is the only path with a **sub-24 h RPO**: recovery to any second inside the last + 14 days, not just "the state at 02:37". Config: + `apps/base/sirius-growth/objectstore-portal-wal.yaml` (`ObjectStore portal-wal`, + store + `retentionPolicy: 14d`), the Cluster's `spec.plugins` + (`barman-cloud.cloudnative-pg.io`, `isWALArchiver: true`, `serverName: portal`) + and `apps/base/sirius-growth/scheduled-backup.yaml` (`ScheduledBackup + portal-daily`, `20 3 * * *` UTC in **six**-field cron, seconds first, + `method: plugin`). The plugin Deployment itself is vendored in + `infrastructure/databases/base/` (§8.4). A fifth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` `wireguard-backup.timer` (nightly 04:13) → `root@10.20.0.1:/root/pihost-backup`. @@ -554,7 +565,7 @@ A fifth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` |---|---|---|---| | `forgejo-data` PVC (`/data`) | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `forgejo-data//` + `latest` symlink | 7 snapshots (hardlinked: 1 full copy + nightly deltas) | | `forgejo/pg` | `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket — no DB password exists in git or in the Job | `db/forgejo-pg-.dump` | 14 | -| `sirius-growth/portal` | two independent copies, on purpose. **(a)** `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket, through exec RBAC in `sirius-growth` — logical, human-readable with any `pg_restore`. **(b)** barman-cloud **continuous WAL archive + daily base backup** (path 4) | (a) `db/sirius-growth-portal-.dump`; (b) `pg-wal-archive` bucket on the Linode: `portal/base//` + `portal/wals/…` | (a) 14 dumps; (b) 14 days of WAL (`retentionPolicy: 14d`) | +| `sirius-growth/portal` | two independent copies, on purpose. **(a)** `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket, through exec RBAC in `sirius-growth` — logical, human-readable with any `pg_restore`. **(b)** barman-cloud **continuous WAL archive + daily base backup** through the CNPG-I plugin (path 4) | (a) `db/sirius-growth-portal-.dump`; (b) `pg-wal-archive` bucket on the Linode: `portal/base//` + `portal/wals/…` | (a) 14 dumps; (b) 14 days of WAL (`ObjectStore.spec.retentionPolicy: 14d`) | | `osint/osint-db` (plain Postgres Deployment, has TimescaleDB + PostGIS) | `pg_dump -Fc -Z6` **inside the pod** over the local socket, using its own `POSTGRES_USER`/`POSTGRES_DB` via exec RBAC in `osint` | `db/osint-osint-db-.dump` | 14 | | `grafana.db` (sqlite) | **sqlite backup API** in a `python:3.12-alpine` pod that mounts the PVC — a `cp` of a live db can capture a torn page; the image is `-distroless`, so there is no shell to exec into | `grafana/grafana-.db` | 14 | | `sgs-leadgen-data` PVC | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `leadgen-data//` + `latest` | 7 | @@ -598,22 +609,29 @@ A fifth path covers the Pi's own hub state: `infrastructure/wireguard/backup/` window**. Worst case on a busy database (every segment full at a typical 3–5× gzip ratio) is ~1.5 GB/day → 21 GB for 14 days, i.e. it would hit the 20 GB cap. The cap is deliberate: Garage answers `507 InsufficientStorage` and - `barman-cloud-backup` fails loudly (red `Backup`/`ScheduledBackup`) rather + barman-cloud fails loudly (a red `Backup`/`ScheduledBackup`) rather than filling the Linode disk. If that ever fires, the lever is - `spec.backup.retentionPolicy` (7d) — not deleting WALs by hand. + `ObjectStore portal-wal` → `spec.retentionPolicy` (7d) — not deleting WALs by + hand. - **The barman credentials are a namespaced Secret, not git**: `sirius-growth/portal-wal-s3` (`ACCESS_KEY_ID` / `ACCESS_SECRET_KEY` / `REGION`), created out of band from Garage key `cnpg-portal-wal` (`GK7f2b4bb1fc9abaec50fde37b`, scope **read+write on `pg-wal-archive` only**, no bucket-create). Recording key IDs is fine; the values are not in git, in the docs, or in any comment. -- **CNPG 1.30 still ships the in-tree barman-cloud integration, and it warns that - 1.31 removes it** (`Warning: Native support for Barman Cloud backups and - recovery is deprecated ... Please migrate existing clusters to the new Barman - Cloud Plugin`). That is why this is on 1.30 only: the plugin (an extra - Deployment + CNPG-I registration + TLS) is the migration path, and it must land - before the operator goes to 1.31. Nothing else here changes when it does — the - bucket layout stays `portal/base` + `portal/wals`. +- **The 1.31 gate is closed — WAL archiving runs on the CNPG-I plugin, not the + in-tree path.** CNPG 1.30 deprecated `spec.backup.barmanObjectStore` and warns + on every apply that 1.31 removes it. `sirius-growth/portal` was migrated on + **2026-11-19** (kanban `t_5df331de`) to the Barman Cloud plugin + (`infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml`, + Deployment `cnpg-system/barman-cloud`, `ObjectStore sirius-growth/portal-wal`, + `Cluster.spec.plugins`, `ScheduledBackup.method: plugin`), so bumping the + operator pin from 1.30.0 to 1.31 no longer breaks archiving or PITR. The bucket + layout did not move: `portal/base` + `portal/wals` are the same objects the + in-tree archiver wrote, and the restore rehearsal in §8.3 ran against that + mixed archive. The plugin needs cert-manager (its mTLS pair is an + `Issuer` + two `Certificate`s), installed as `cert-manager` HelmRelease v1.21.3 + — see §8.4. **Accepted gaps (with the reason, not just a TODO):** @@ -640,11 +658,15 @@ plain Deployment and cannot use CNPG backup at all. A new CloudNativePG cluster is **not** picked up automatically by either mechanism. For dumps: add `/` to `CNPG_TARGETS` in the CronJob env *and* an equivalent exec-only Role/RoleBinding for the `forgejo/cluster-backup` -ServiceAccount in that namespace. For barman: add `spec.backup.barmanObjectStore` -with a `destinationPath` of `s3://pg-wal-archive` (the bucket root — the server -name, defaulting to the cluster name, becomes the prefix, so clusters share one -bucket without colliding), the same `sirius-growth/portal-wal-s3`-shaped Secret -in that namespace, and a `ScheduledBackup`. +ServiceAccount in that namespace. For WAL archiving: create an `ObjectStore` in +that namespace whose `spec.configuration.destinationPath` is +`s3://pg-wal-archive` (the bucket root — the plugin appends the barman server +name, which defaults to the cluster name, so clusters share one bucket without +colliding), point its `s3Credentials` at a `sirius-growth/portal-wal-s3`-shaped +Secret in that namespace, give it its own `retentionPolicy`, add +`spec.plugins: [{name: barman-cloud.cloudnative-pg.io, isWALArchiver: true, +parameters: {barmanObjectName: }}]` to the Cluster and a +`ScheduledBackup` with `method: plugin`. ### 8.2 Restoring @@ -713,10 +735,11 @@ sudo systemctl start wg-quick@wg0 && sudo wg show ### 8.3 Point-in-time recovery (`sirius-growth/portal`) -Rehearsed end to end on **2026-11-19** (task `t_ce7d6772`) against the live -archive: a marker row was written, 10 s later a second, unwanted row was written, -and a throwaway cluster was restored with `targetTime` between the two. The -marker came back, the later row did not. +Rehearsed end to end twice: **2026-11-19** with the in-tree barman-cloud archiver +(task `t_ce7d6772`) and again the same day **on the CNPG-I Barman Cloud plugin** +(task `t_5df331de`, §8.4) — marker row → forced WAL switch → unwanted row → +forced WAL switch → throwaway cluster restored with `targetTime` between the +two. Both times the marker came back and the later row did not. **Step 1 — establish the target time.** Take it from the data, never from memory: @@ -729,6 +752,8 @@ date -u +%FT%TZ **Step 2 — restore into a throwaway cluster.** Never into `portal` itself while it is serving: CNPG recovery bootstraps a *new* data dir from the archive. +`externalClusters[].plugin` replaces `barmanObjectStore`; `serverName` is the +barman prefix and must stay the **source** cluster name. ```yaml apiVersion: postgresql.cnpg.io/v1 @@ -745,17 +770,14 @@ spec: recovery: source: portal-wal recoveryTarget: - targetTime: "2026-11-19T22:35:15Z" # UTC, RFC3339 + targetTime: "2026-11-19T23:05:00Z" # UTC, RFC3339 externalClusters: - name: portal-wal - barmanObjectStore: - destinationPath: s3://pg-wal-archive - endpointURL: http://10.10.0.5:3900 - serverName: portal # MUST be the *source* cluster name - s3Credentials: - accessKeyId: {name: portal-wal-s3, key: ACCESS_KEY_ID} - secretAccessKey: {name: portal-wal-s3, key: ACCESS_SECRET_KEY} - region: {name: portal-wal-s3, key: REGION} + plugin: + name: barman-cloud.cloudnative-pg.io + parameters: + barmanObjectName: portal-wal # the ObjectStore in this namespace + serverName: portal # MUST be the *source* cluster name ``` ```bash @@ -773,6 +795,25 @@ kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \ psql -U postgres -tAc "select pg_is_in_recovery(), pg_last_xact_replay_timestamp()" ``` +Rehearsal transcript on the plugin path (2026-11-19 23:04–23:06 UTC), target +`2026-11-19T23:05:00Z`, marker written 23:04:53.07, unwanted row 23:05:15.80: + +``` +# live primary, the mistake + 1 | MARKER-plugin-before-target | 2026-11-19 23:04:53.072104+00 + 2 | POISON-plugin-after-target | 2026-11-19 23:05:15.798408+00 +# pg_stat_archiver after forcing both segments out: ...062 (23:04:54), ...063 (23:05:16), failed_count 6 (historical, static) + +# restored cluster portal-pitr-test (targetTime 23:05:00Z) +id | note | at +----+-----------------------------+------------------------------- + 1 | MARKER-plugin-before-target | 2026-11-19 23:04:53.072104+00 +(1 row) +select count(*) from pitr_probe where note like 'POISON%' -> 0 +select pg_is_in_recovery(), pg_last_xact_replay_timestamp() -> f| +clients=4 calendar_tokens=3 applications=1 # identical to the primary +``` + `pg_is_in_recovery() = f` on a single-instance recovery cluster means replay finished and it has already been promoted. **A recovery cluster is writable the moment it is Ready** — do not leave `portal-pitr-test` running, and do not point @@ -797,6 +838,36 @@ timestamp near the present. (§8.2 step 2) — 24 h RPO, logical, and readable without barman. That is exactly why `sirius-growth/portal` stayed in `CNPG_TARGETS`. +### 8.4 The CNPG-I Barman Cloud plugin (how it is wired) + +Active since **2026-11-19**. Three moving parts, all in git: + +| Piece | Where | Notes | +|---|---|---| +| Plugin Deployment | `infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml` (vendored verbatim, sha256 `aee61468…7155`), patched only for `--log-level=info` + resources | `cnpg-system/barman-cloud`, port 9090, `replicas: 1`; **registered through Service annotations** `cnpg.io/pluginName: barman-cloud.cloudnative-pg.io` + `cnpg.io/pluginPort`/`pluginClientSecret`/`pluginServerSecret` — there is no `Plugin` CR in CNPG 1.30; delete the Service and the operator deregisters it | +| mTLS | `infrastructure/controllers/cert-manager/` (HelmRelease `cert-manager` v1.21.3, `crds.enabled: true`) issuing `barman-cloud-server-tls` / `barman-cloud-client-tls` from the vendored `Issuer` + `Certificate`s | cert-manager is a hard dependency of the plugin manifest, not a nice-to-have | +| Store + wiring | `ObjectStore sirius-growth/portal-wal`, `Cluster portal` `spec.plugins`, `ScheduledBackup portal-daily` `method: plugin` | `ObjectStore` must live in the Cluster's namespace, and its `serverName` field must stay **empty** (the CRD enforces this); the prefix comes from `spec.plugins[].parameters.serverName` | + +Instance side: the operator injects an init-container sidecar +(`plugin-barman-cloud`, restartable sidecar) into `portal-1` and mounts a +`plugins` volume, which is why the Cluster restarted its primary once at +migration time. That sidecar runs `barman-cloud-wal-archive` / +`barman-cloud-backup` and enforces `retentionPolicy` every 30 min; the archive +URL it uses is `s3://pg-wal-archive portal ` — same prefix as before. + +Metrics change family with the archiver: `barman_cloud_cloudnative_pg_io_*` +(`…_last_available_backup_timestamp`, `…_first_recoverability_point`, +`…_last_failed_backup_timestamp`) replace `cnpg_collector_*` for this cluster. +The CNPG Grafana board accepts both. The deprecated +`cnpg_collector_last_available_backup_timestamp` is still *scraped* for portal +and holds the pre-migration value (22:34 UTC), so a panel that selects it alone +freezes at the last in-tree backup — that is why §8.4's dashboard change puts +the plugin metric first in the `or`. + +Dependency order in Flux: `cert-manager` → `databases` (plugin + `ObjectStore` +CRD) → `apps` (the `ObjectStore` CR and the Cluster that references it). + + --- ## 9. Known hazards and runbook pointers @@ -892,3 +963,16 @@ All times 2026-10-26 UTC. `kubeconfig` on the Legion admin laptop → `https://1 | 36 | siriussec: `curl :2381/metrics` (etcd) | `wal_fsync` 158 >8.192 s / 2,518 >2.048 s of 14,813,192; `backend_commit` 187 >8.192 s of 6,652,027; 99.6 %/99.7 % ≤32 ms — matches the stated stall profile, so this is spiky contention, not a failing disk | **Not verified, deliberately:** Cloudflare DNS records, Forgejo's `app.ini`, any secret material, and the SG-VPS/phone spoke routing beyond what the Linode's `wg show` reports. + +**CNPG-I Barman Cloud plugin migration, verified 2026-11-19 22:57–23:07 UTC (commits `f3a8233`, `c452552`; kanban `t_5df331de`):** + +| # | Command | Key result | +|---|---|---| +| 37 | `kubectl -n cert-manager get pods`; `kubectl -n flux-system get kustomization` | controller/webhook/cainjector `1/1 Running`; all 7 Kustomizations `Ready=True` at the same revision, `databases` `dependsOn cert-manager`, `apps` `dependsOn databases` | +| 38 | `kubectl -n cnpg-system get pods,certificate` | `barman-cloud-7b779d49d8-2pnbk 1/1 Running`; `barman-cloud-client` + `barman-cloud-server` certificates `READY=True` — the operator logged `Registered plugin` for `barman-cloud.cloudnative-pg.io` | +| 39 | `kubectl -n sirius-growth get cluster portal -o jsonpath='{.status.pluginStatus}'` | `[{name: barman-cloud.cloudnative-pg.io, version: 0.16.0, capabilities: [TYPE_RECONCILER_HOOKS, TYPE_LIFECYCLE_SERVICE, TYPE_INSTANCE_SIDECAR_INJECTION]}]`; pod `portal-1` now carries the `plugin-barman-cloud` init-sidecar and `plugins` volume; Cluster `Ready=True` | +| 40 | `kubectl -n sirius-growth logs portal-1 -c plugin-barman-cloud` | `Executing barman-cloud-wal-archive … ["--gzip","--endpoint-url","http://10.10.0.5:3900","--cloud-provider","aws-s3","s3://pg-wal-archive","portal", …05D]` → `Archived WAL file … elapsedWalTime 0.586`; retention runnable applied `14d` | +| 41 | `kubectl -n sirius-growth get backup portal-plugin-proof-1 -o wide` | `METHOD plugin`, `PHASE completed` (on-demand base backup through the plugin) | +| 42 | `aws --endpoint-url http://10.10.0.5:3900 s3 ls --recursive s3://pg-wal-archive/` (from a pod, Secret `portal-wal-s3`) | `portal/base/20261119T223452/…` (in-tree) **and** `portal/base/20261119T230300/…` (plugin) side by side, `portal/wals/…` continuous — the prefix did not move; 4 objects under `base/`, 10 under `wals/` | +| 43 | PITR rehearsal: marker `23:04:53.07`, poison `23:05:15.80`, `targetTime 2026-11-19T23:05:00Z` | restored `portal-pitr-test` → marker row present, `count(POISON%)=0`, `pg_is_in_recovery()=f`, `clients 4 / calendar_tokens 3 / applications 1` identical to the primary; test cluster + PVC deleted, probe table dropped afterwards | +| 44 | Prometheus (`/api/v1/query`) | `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` = 1795129385 (23:03:05, the plugin backup), `…_first_recoverability_point` = 1795127697; the legacy `cnpg_collector_last_available_backup_timestamp` for `portal` still returns the **pre-migration** 1795127697 — hence the dashboard's `or` lists the plugin metric first | diff --git a/infrastructure/garage-linode/README.md b/infrastructure/garage-linode/README.md index 939625d..6ee6737 100644 --- a/infrastructure/garage-linode/README.md +++ b/infrastructure/garage-linode/README.md @@ -1,9 +1,9 @@ # Garage on the Linode — the CloudNativePG WAL archive A **second, independent** single-node Garage on the Linode VPS. It holds one -bucket, `pg-wal-archive`, and its only consumer is CloudNativePG's barman-cloud -integration for `sirius-growth/portal` (continuous WAL archiving + daily base -backups → point-in-time recovery). +bucket, `pg-wal-archive`, and its only consumer is the **CNPG-I Barman Cloud +plugin** archiving for `sirius-growth/portal` (continuous WAL archiving + daily +base backups → point-in-time recovery). It is **not** the Pi's Garage (`infrastructure/garage/`, node `d053db4dfc97bf78`). Different host, different `node_key`, different metadata @@ -99,8 +99,9 @@ Measured 2026-11-19: | Steady state (quiet) | ~6 MB WAL/day + 4.5 MB base backup/day ≈ **150 MB per 14-day window** | | Worst case (every segment full, 3–5× gzip) | ~1.5 GB/day ≈ 21 GB per 14 days — would hit the cap | -Retention is `spec.backup.retentionPolicy: "14d"` on the Cluster, enforced by -barman-cloud when a backup completes. The 20 GB cap is deliberate: when it is +Retention is `spec.retentionPolicy: "14d"` on the `ObjectStore` (`portal-wal` in +`sirius-growth`), enforced by the plugin's instance sidecar (every 30 min), not +by the Cluster. The 20 GB cap is deliberate: when it is reached Garage returns `507 InsufficientStorage` and the `Backup` / `ScheduledBackup` goes red — a visible failure instead of a full Linode disk. The response to that is to lower the retention policy to `7d`, or to grow the @@ -110,7 +111,8 @@ continuity and every PITR target that depends on the deleted segment). ## How the archive is laid out `destinationPath: s3://pg-wal-archive` (bucket root) with the barman server name -defaulting to the cluster name, so: +explicitly set to the cluster name (`Cluster.spec.plugins[].parameters.serverName: +portal`), so: ``` pg-wal-archive/portal/base/20261119T223452/{backup.info,data.tar.gz} diff --git a/infrastructure/garage-linode/pitr-restore.md b/infrastructure/garage-linode/pitr-restore.md index bdc1f6f..f78add0 100644 --- a/infrastructure/garage-linode/pitr-restore.md +++ b/infrastructure/garage-linode/pitr-restore.md @@ -1,54 +1,71 @@ # Restore notes — point-in-time recovery for `sirius-growth/portal` -Rehearsed end to end on **2026-11-19** (kanban task `t_ce7d6772`) against the live -archive. This file records the commands and the actual output of that rehearsal, -so the next person restores from a transcript instead of a hope. +Rehearsed end to end on **2026-11-19** against the live archive, twice: once with +the in-tree barman-cloud archiver (kanban `t_ce7d6772`) and once **after the +migration to the CNPG-I Barman Cloud plugin** (kanban `t_5df331de`). This file +records the commands and the actual output of the plugin rehearsal, so the next +person restores from a transcript instead of a hope. The archive: Garage on the Linode, bucket `pg-wal-archive`, `http://10.10.0.5:3900` over the WireGuard mesh, credentials in Secret `sirius-growth/portal-wal-s3`. -Producer: `spec.backup.barmanObjectStore` on `Cluster sirius-growth/portal` -(WAL archiving continuous, `ScheduledBackup portal-daily` at 03:20 UTC, -`retentionPolicy: 14d`). +Producer: the **Barman Cloud plugin** — `ObjectStore sirius-growth/portal-wal` +(store + `retentionPolicy: 14d`), `Cluster portal` `spec.plugins` +(`isWALArchiver: true`, `serverName: portal`) and `ScheduledBackup portal-daily` +at 03:20 UTC with `method: plugin`. WAL archiving is continuous; base backups are +daily plus on demand. ## 0. Is the archive actually healthy? ```bash kubectl -n sirius-growth exec portal-1 -c postgres -- \ psql -U postgres -tAc "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver" -# 00000001000000000000005B|2026-11-19 22:40:30.1+00|0 +# 000000010000000000000063|2026-11-19 23:05:16.834323+00|6 ``` -`failed_count` must be 0 and `last_archived_time` must be minutes old. A -`targetTime` after the last archived WAL cannot be reached — recovery stops at -the last segment it can fetch. +`last_archived_time` must be minutes old and the WAL name must advance when you +force a segment (`select pg_switch_wal()`). A `targetTime` after the last +archived WAL cannot be reached — recovery stops at the last segment it can fetch. + +`failed_count` is **cumulative for the life of the instance**, not a "current +health" gauge: the 6 recorded here are from the pre-migration in-tree archiver +and the primary restart during the switch. What matters is that it does not +*increase* while you watch — check it before and after a forced segment. + +What actually wrote the last segment is visible in the sidecar log, which names +barman's own arguments (server name `portal`, bucket root `s3://pg-wal-archive`): ```bash -kubectl -n sirius-growth get backup -o wide # newest barmanObjectStore Backup: completed -kubectl -n sirius-growth get scheduledbackup # portal-daily, LAST BACKUP set +kubectl -n sirius-growth logs portal-1 -c plugin-barman-cloud --tail=20 +# {"msg":"Executing barman-cloud-wal-archive", ... "options":["--gzip","--endpoint-url","http://10.10.0.5:3900", +# "--cloud-provider","aws-s3","s3://pg-wal-archive","portal","/var/lib/postgresql/data/pgdata/pg_wal/"]} +# {"msg":"Archived WAL file","walName":"...","elapsedWalTime":0.586...} +``` + +```bash +kubectl -n sirius-growth get backup -o wide # newest Backup: METHOD plugin, PHASE completed +kubectl -n sirius-growth get scheduledbackup # portal-daily, method plugin, LAST BACKUP set ``` ## 1. Prove the marker, then make the mistake -The rehearsal wrote a marker, forced the WAL out, waited, then wrote a second -row that must *not* survive recovery: - ```bash q() { kubectl -n sirius-growth exec portal-1 -c postgres -- psql -U postgres -d portal -tAc "$1"; } -q "insert into pitr_probe(note) values ('MARKER-before-target') returning id, at" -# 3|2026-11-19 22:35:06.127778+00 +q "create table if not exists pitr_probe(id bigserial primary key, note text, at timestamptz default now())" +q "insert into pitr_probe(note) values ('MARKER-plugin-before-target') returning id, at" +# 1|2026-11-19 23:04:53.072104+00 q "select pg_switch_wal()" ; sleep 12 -q "select last_archived_wal, last_archived_time from pg_stat_archiver" -# 000000010000000000000059|2026-11-19 22:35:07.089783+00 +q "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver" +# 000000010000000000000062|2026-11-19 23:04:54.052315+00|6 sleep 10 -q "insert into pitr_probe(note) values ('POISON-after-target') returning id, at" -# 4|2026-11-19 22:35:28.959782+00 +q "insert into pitr_probe(note) values ('POISON-plugin-after-target') returning id, at" +# 2|2026-11-19 23:05:15.798408+00 q "select pg_switch_wal()" ; sleep 12 -q "select last_archived_wal, last_archived_time from pg_stat_archiver" -# 00000001000000000000005A|2026-11-19 22:35:29.906592+00 +q "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver" +# 000000010000000000000063|2026-11-19 23:05:16.834323+00|6 ``` -The target is therefore **`2026-11-19T22:35:15Z`** — 9 s after the marker, 14 s -before the row that must be lost. Note that WAL `…05A` (which contains the poison +The target is therefore **`2026-11-19T23:05:00Z`** — 7 s after the marker, 15 s +before the row that must be lost. Note that WAL `…063` (which contains the poison row) *is* in the archive: the restore has to choose to stop, it is not starved of data. @@ -75,23 +92,22 @@ spec: recovery: source: portal-wal recoveryTarget: - targetTime: "2026-11-19T22:35:15Z" + targetTime: "2026-11-19T23:05:00Z" externalClusters: - name: portal-wal - barmanObjectStore: - destinationPath: s3://pg-wal-archive - endpointURL: http://10.10.0.5:3900 - serverName: portal # MUST match the source Cluster name - s3Credentials: - accessKeyId: {name: portal-wal-s3, key: ACCESS_KEY_ID} - secretAccessKey: {name: portal-wal-s3, key: ACCESS_SECRET_KEY} - region: {name: portal-wal-s3, key: REGION} + plugin: # was barmanObjectStore before the plugin migration + name: barman-cloud.cloudnative-pg.io + parameters: + barmanObjectName: portal-wal # ObjectStore in THIS namespace + serverName: portal # MUST be the *source* Cluster name ``` `serverName` is not optional: it is the barman prefix (`portal/base`, -`portal/wals`). Omit it and the restore cluster looks for its own name and finds -an empty history. `targetTime` is UTC RFC3339 — a wrong timezone silently -restores the wrong hour. +`portal/wals`). Omit it and the plugin falls back to the *restoring* cluster's +name (`portal-pitr-test`) and finds an empty history. `targetTime` is UTC +RFC3339 — a wrong timezone silently restores the wrong hour. The ObjectStore's +own `spec.configuration.serverName` must stay empty (its CRD rejects anything +else); the prefix always comes from this plugin parameter. The operator restores the base backup, replays WAL, stops at the target and promotes: @@ -108,9 +124,9 @@ portal-pitr-test 1 1 Cluster in healthy state portal-pitr-test-1 ``` $ kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \ psql -U postgres -d portal -c "select id, note, at from pitr_probe order by id" - id | note | at -----+----------------------+------------------------------- - 3 | MARKER-before-target | 2026-11-19 22:35:06.127778+00 + id | note | at +----+-----------------------------+------------------------------- + 1 | MARKER-plugin-before-target | 2026-11-19 23:04:53.072104+00 (1 row) $ ... -tAc "select count(*) from pitr_probe where note like 'POISON%'" @@ -122,7 +138,7 @@ Marker present, post-target row gone. The rest of the database came back with it `clients 4 = 4`, `calendar_tokens 3 = 3`, `applications 1 = 1` against the primary at that moment. -``` +```bash $ ... -tAc "select pg_is_in_recovery()" f # replay finished, instance promoted ``` @@ -134,6 +150,8 @@ why nothing may point application traffic at it before you decide to. ```bash kubectl -n sirius-growth delete cluster portal-pitr-test +kubectl -n sirius-growth delete pvc -l cnpg.io/cluster=portal-pitr-test +kubectl -n sirius-growth exec portal-1 -c postgres -- psql -U postgres -d portal -tAc "drop table if exists pitr_probe" ``` ## 4. Making the restored data the real data @@ -148,29 +166,44 @@ Two shapes, both legitimate: the recovered data directory. Slower, destructive, and easy to get wrong — only with the app scaled to zero. -Either way, take a fresh base backup once the decision is made -(`kubectl apply` a `Backup` CR against the surviving cluster) so the archive has -a post-recovery base rather than one from before the incident. +Either way, take a fresh base backup once the decision is made (a `Backup` CR with +`method: plugin`, or `kubectl cnpg backup -n sirius-growth portal --method=plugin +--plugin-name=barman-cloud.cloudnative-pg.io`) so the archive has a post-recovery +base rather than one from before the incident. ## Gotchas that cost time -- **Flux owns `apps/base/sirius-growth/cluster.yaml`.** A hand `kubectl apply` of - a new `spec.backup` is reverted by the `apps` Kustomization within its 1 min - interval. Config changes belong in the branch/PR. (During the rehearsal the - `kustomize-controller` Deployment was scaled to 0 for the test window and - scaled back afterwards; `Backup`/`Cluster` objects created by hand are not in - the Kustomization inventory, so they are not pruned.) +- **Flux owns `apps/base/sirius-growth/`.** A hand `kubectl apply` of the Cluster, + the ObjectStore or the ScheduledBackup is reverted by the `apps` Kustomization + within its 1 min interval. Config changes belong in the branch/PR. (`Cluster` + and `Backup` objects created by hand for a rehearsal are not in the + Kustomization inventory, so they are not pruned — but the objects Flux *does* + own are reverted.) - **`ScheduledBackup.spec.schedule` is six-field cron, seconds first.** `0 20 3 * * *` = 03:20:00 UTC. Copying a five-field crontab string silently means "every minute" in the first field. +- **Two different `serverName`s exist and only one may be set.** On the + `ObjectStore` it must be absent (CRD CEL rule); on the Cluster's + `spec.plugins[].parameters` / `externalClusters[].plugin.parameters` it is the + prefix. Set the wrong one and archiving writes to `portal-/`, which + silently abandons the existing 14-day window. - **The bucket prefix is `portal/portal/…` only if you get `destinationPath` - wrong.** Use `s3://pg-wal-archive` for the bucket root; barman appends the - server name. -- **CNPG 1.30 warns that in-tree barman-cloud is removed in 1.31.** If that - upgrade happens, migrate to the Barman Cloud Plugin first; until then the - archives remain readable by `barman-cloud-restore` in the same container image. -- **If archiving has failed** (`pg_stat_archiver.failed_count > 0`), fix it and - let a fresh base backup complete before trusting any recent `targetTime`. + wrong.** Use `s3://pg-wal-archive` for the bucket root; the server name is + appended. +- **Plugin, not in-tree.** The operator's in-tree barman-cloud support is + deprecated in 1.30 and removed in 1.31; `spec.backup.barmanObjectStore` on a + 1.31 operator would leave the cluster with no archiver at all. Restore config + is `externalClusters[].plugin` + `parameters.barmanObjectName`, and the store + itself is an `ObjectStore` CR in the cluster's namespace. +- **Retention moved.** `retentionPolicy` lives on the `ObjectStore` now, enforced + by the plugin sidecar every 30 min — not on the Cluster, and not "at backup + time". +- **Backup metrics changed family.** `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` + replaces `cnpg_collector_last_available_backup_timestamp`. The old series for + `portal` still shows the pre-migration timestamp, so alert/dashboard queries + must prefer the new one (see `monitoring/controllers/home/dashboards/build.py`). +- **If archiving has failed** (`pg_stat_archiver.failed_count` increasing), fix it + and let a fresh base backup complete before trusting any recent `targetTime`. - **Fallback when the archive is unusable:** the nightly `pg_dump` in `forgejo/cluster-backup` (`db/sirius-growth-portal-.dump`, 14 retained, §8.2 step 2 of `docs/cluster-overview.md`). 24 h RPO, logical, independent of diff --git a/monitoring/controllers/home/dashboards/build.py b/monitoring/controllers/home/dashboards/build.py index 88868d0..fe46072 100644 --- a/monitoring/controllers/home/dashboards/build.py +++ b/monitoring/controllers/home/dashboards/build.py @@ -245,9 +245,9 @@ cnpg = [ {"h": 5, "w": 4, "x": 16, "y": 1}, desc="1 = the operator is asking for a manual switchover (e.g. after a fencing event).", thresholds=[{"color": "green", "value": None}, {"color": "red", "value": 1}]), - stat("Last available backup", [target('max by (namespace) (cnpg_collector_last_available_backup_timestamp{%s} or barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{%s})' % (CLUSTER_NS, CLUSTER_NS))], + stat("Last available backup", [target('max by (namespace) (barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{%s} or cnpg_collector_last_available_backup_timestamp{%s})' % (CLUSTER_NS, CLUSTER_NS))], {"h": 5, "w": 4, "x": 20, "y": 1}, unit="dateTimeAsIso", - desc="0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, which exposes its own metric family `barman_cloud_cloudnative_pg_io_*`; the in-tree `cnpg_collector_*` name is kept in the `or` for any cluster still on the deprecated path. A 0 means neither series exists.", + desc="0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, whose metric is `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp`; the deprecated `cnpg_collector_*` name is the fallback for any cluster still on the in-tree path. Order matters: the legacy series is still scraped for portal and holds the PRE-migration timestamp, so it must not win the `or`.", thresholds=[{"color": "red", "value": None}, {"color": "green", "value": 1}]), row("Throughput", 6), diff --git a/monitoring/controllers/home/dashboards/cnpg-postgres.yaml b/monitoring/controllers/home/dashboards/cnpg-postgres.yaml index 56c7895..5b11a55 100644 --- a/monitoring/controllers/home/dashboards/cnpg-postgres.yaml +++ b/monitoring/controllers/home/dashboards/cnpg-postgres.yaml @@ -423,7 +423,7 @@ data: "id": 29, "type": "stat", "title": "Last available backup", - "description": "0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, which exposes its own metric family `barman_cloud_cloudnative_pg_io_*`; the in-tree `cnpg_collector_*` name is kept in the `or` for any cluster still on the deprecated path. A 0 means neither series exists.", + "description": "0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, whose metric is `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp`; the deprecated `cnpg_collector_*` name is the fallback for any cluster still on the in-tree path. Order matters: the legacy series is still scraped for portal and holds the PRE-migration timestamp, so it must not win the `or`.", "datasource": { "type": "prometheus", "uid": "prometheus" @@ -440,7 +440,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max by (namespace) (cnpg_collector_last_available_backup_timestamp{namespace=~\"$namespace\"} or barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{namespace=~\"$namespace\"})", + "expr": "max by (namespace) (barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{namespace=~\"$namespace\"} or cnpg_collector_last_available_backup_timestamp{namespace=~\"$namespace\"})", "refId": "A", "editorMode": "code", "range": true, From 4ffe40e6ca6ff9161d7adc96e01bb6ba0834aacb Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 19:14:54 -0500 Subject: [PATCH 57/88] apps(siriusdevops): pin site to c704a2e (post-PR-12 build) --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 00b5cd3..5b0d145 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:4d03fc814d39faaf5d8cc64b794aa4bc19f72995 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:c704a2e6ab83ef65780c571ac0220a3268c93101 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From c6e008121721545bbe396a6383198b42950fa08d Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 19:33:54 -0500 Subject: [PATCH 58/88] =?UTF-8?q?apps(siriusdevops):=20pin=20contact-api?= =?UTF-8?q?=20to=208642f1a=20(Telegram=20Markdown=E2=86=92HTML=20lead-drop?= =?UTF-8?q?=20fix)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-api.yaml b/apps/base/siriusdevops/deployment-api.yaml index 43b5bba..79b475e 100644 --- a/apps/base/siriusdevops/deployment-api.yaml +++ b/apps/base/siriusdevops/deployment-api.yaml @@ -21,7 +21,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: contact-api - image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13 + image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:8642f1a14b1dd9f217e32856b7a9ea0a0c37e3aa imagePullPolicy: IfNotPresent command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"] ports: From 1b27ad11208d7725f9735267405021fb304c7a23 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 22:59:37 -0500 Subject: [PATCH 59/88] apps(osint): pin amd64-fe2b5df369d0 (per-article news blips: geolocation API + map layer) --- apps/base/osint/README.md | 4 ++-- apps/base/osint/app-deployment.yaml | 4 ++-- apps/base/osint/camera-deployment.yaml | 2 +- apps/base/osint/ingester-deployment.yaml | 2 +- apps/base/osint/news-summarizer-deployment.yaml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index fc41c92..9479733 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -10,12 +10,12 @@ instead of a host Docker container on the Pi. |---|---|---| | `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | | `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | -| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-58f71f5b4520` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | +| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-fe2b5df369d0` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | | `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | | `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop | -| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-d04ddc9afacb` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | +| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fe2b5df369d0` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy co-location + local-path PVs). diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index 91cc7cb..74108c9 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 imagePullPolicy: IfNotPresent ports: - containerPort: 8000 diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml index 04a79ed..a48bdfc 100644 --- a/apps/base/osint/camera-deployment.yaml +++ b/apps/base/osint/camera-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: camera-service - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 imagePullPolicy: IfNotPresent command: ["python", "app/run_camera_service.py"] envFrom: diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 6d5e711..047a55a 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml index edfec15..163b6d0 100644 --- a/apps/base/osint/news-summarizer-deployment.yaml +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: news-summarizer - image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-d04ddc9afacb + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0 imagePullPolicy: IfNotPresent # Loop: batch the last window, call Nous Portal, write summaries. command: ["python", "run_news_summarizer.py"] From 7ae4ac2ee3dc98890d146b74aee1d8e4cdc9581b Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Thu, 19 Nov 2026 23:36:56 -0500 Subject: [PATCH 60/88] =?UTF-8?q?docs(osint):=20CI=20builds=20the=20amd64?= =?UTF-8?q?=20cluster=20images=20now=20=E2=80=94=20retire=20the=20manual-b?= =?UTF-8?q?uild=20instructions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/osint/README.md | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index 9479733..fad61ac 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -22,18 +22,30 @@ co-location + local-path PVs). ## Images -The upstream CI (`.forgejo/workflows/build.yml` in `sirius/osint-dashboard`) -builds **arm64** for the Pi via `runs-on: docker`. The cluster is amd64, so the -cluster images were built on an amd64 host and pushed to the Forgejo registry -over a `kubectl -n forgejo port-forward svc/forgejo 3000:3000` (Cloudflare -rejects layer uploads ≳100 MB on the public hostname). **Build from a detached -worktree at the merge sha, never from the main checkout** — Legion's -`~/osint-dashboard` sits on a feature branch, and a `docker build` there once -produced a `:amd64-` image that carried the right tag and none of the -commit's code (that tag was deleted from the registry; `-r1` is the real build). +**CI builds the cluster images.** Since PR #63 in `sirius/osint-dashboard`, +`.forgejo/workflows/build.yml` runs on the `amd64` runner (`runs-on: amd64`), +tags `amd64-`, and pushes straight into the in-cluster registry +(`forgejo.forgejo.svc.cluster.local:3000`, plain HTTP, whitelisted by +`--insecure-registry` on the runner's dind). Deploying is then just a pin +change here in `apps/base/osint/` — check the run's `## Pin in homek8s` summary +for the exact tags. Builds are **path-filtered**, so one image can be several +commits older than another: the app tag is normally master tip, the summarizer +tag is whichever commit last touched `news/summerizer/`. + +Do not build these by hand and push over a `:amd64-` tag: that replaces +CI's manifest, and Forgejo's registry garbage-collects the displaced digest, so +the CI artifact cannot be pulled back. If you need a tag rebuilt, dispatch CI +instead: `POST /api/v1/repos/sirius/osint-dashboard/actions/workflows/build.yml/dispatches` +with `{"ref":"master","inputs":{"rebuild_all":"true"}}`. + +Manual builds exist only as a historical fallback (pre-#63 images, or a CI +outage) — and then **build from a detached worktree at the merge sha, never +from the main checkout**: Legion's `~/osint-dashboard` sits on a feature +branch, and a `docker build` there once produced a `:amd64-` image that +carried the right tag and none of the commit's code. ```bash -# from the manifests repo root; build the merge sha, not whatever the checkout has +# fallback only — the normal path is: let CI build, then pin the tag here git -C ~/osint-dashboard fetch origin git -C ~/osint-dashboard worktree add --detach /tmp/osint-build origin/master cd /tmp/osint-build && SHA=$(git rev-parse --short=12 HEAD) && TAG="amd64-$SHA" From 24785a54e8ddd8115d04c4fddde31d80d14d336a Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 19 Nov 2026 23:48:48 -0500 Subject: [PATCH 61/88] apps(osint): pin amd64-915f6cbe25be (critical-news renderer fix + Blue Marble default + slower ticker) --- apps/base/osint/README.md | 2 +- apps/base/osint/app-deployment.yaml | 4 ++-- apps/base/osint/camera-deployment.yaml | 2 +- apps/base/osint/ingester-deployment.yaml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index fad61ac..eb44b51 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -10,7 +10,7 @@ instead of a host Docker container on the Pi. |---|---|---| | `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | | `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | -| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-fe2b5df369d0` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | +| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-915f6cbe25be` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | | `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index 74108c9..93ebf7f 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be imagePullPolicy: IfNotPresent ports: - containerPort: 8000 diff --git a/apps/base/osint/camera-deployment.yaml b/apps/base/osint/camera-deployment.yaml index a48bdfc..4b3d0f8 100644 --- a/apps/base/osint/camera-deployment.yaml +++ b/apps/base/osint/camera-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: camera-service - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be imagePullPolicy: IfNotPresent command: ["python", "app/run_camera_service.py"] envFrom: diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 047a55a..796f336 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -23,7 +23,7 @@ spec: kubernetes.io/hostname: siriussec containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fe2b5df369d0 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: From e63ba147913b5447ac85441aac9c30931d3eb706 Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 20 Nov 2026 18:31:15 -0500 Subject: [PATCH 62/88] apps(siriusdevops): pin site to 799afe40 (DevOps-repositioned build) --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 5b0d145..5be80b1 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:c704a2e6ab83ef65780c571ac0220a3268c93101 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:799afe40192182cd418652a638376f06e3b1adeb imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 9ad79263ab07499899300d4ac577ba6be5ffd3d9 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 20 Nov 2026 18:46:17 -0500 Subject: [PATCH 63/88] apps(forgejo): disable self-registration (FORGEJO__service__DISABLE_REGISTRATION=true) Bot signups: 5845 accounts, /user/sign_up served 200. Lock to admin-only account creation via env (config is env-driven, not app.ini). --- apps/base/forgejo/deployment.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/base/forgejo/deployment.yaml b/apps/base/forgejo/deployment.yaml index 680a922..4a430ea 100644 --- a/apps/base/forgejo/deployment.yaml +++ b/apps/base/forgejo/deployment.yaml @@ -55,6 +55,9 @@ spec: value: "true" - name: FORGEJO__packages__ENABLED value: "true" + # Bot signup lockdown: admin-only account creation (web + API). + - name: FORGEJO__service__DISABLE_REGISTRATION + value: "true" volumeMounts: - name: data mountPath: /data From f969dcf4ca216816775e3b09cd7504722d6c4cef Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 16:24:09 -0500 Subject: [PATCH 64/88] storage: add linode-local StorageClass + provisioner (local-path-linode) Adds an independent local-path-provisioner pinned to the linode worker with its own ConfigMap (local-path-config-linode), helper pod, and StorageClass local-path-linode. The existing siriussec provisioner, its ConfigMap, the local-path StorageClass (still the cluster default) and every existing PVC/PV are untouched. --- infrastructure/storage/kustomization.yaml | 1 + infrastructure/storage/local-path-linode.yaml | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 infrastructure/storage/local-path-linode.yaml diff --git a/infrastructure/storage/kustomization.yaml b/infrastructure/storage/kustomization.yaml index e317fb0..6a6e563 100644 --- a/infrastructure/storage/kustomization.yaml +++ b/infrastructure/storage/kustomization.yaml @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - local-path-storage.yaml + - local-path-linode.yaml diff --git a/infrastructure/storage/local-path-linode.yaml b/infrastructure/storage/local-path-linode.yaml new file mode 100644 index 0000000..f432cbd --- /dev/null +++ b/infrastructure/storage/local-path-linode.yaml @@ -0,0 +1,122 @@ +# Second local-path provisioner, pinned to the `linode` worker. +# +# The original `local-path` StorageClass keeps its single-replica provisioner on +# siriussec (and its helper pod pinned there), so a PVC consumed by a pod on +# linode would have its directory created on the ThinkPad's disk. This file adds +# an independent provisioner + StorageClass whose volumes live on linode's own +# disk. `local-path` remains the cluster default; nothing here touches it. +# +# Volumes land under /opt/local-path-provisioner/pvc-__ on linode. +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: local-path-config-linode + namespace: local-path-storage +data: + config.json: |- + { + "nodePathMap":[ + { + "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", + "paths":["/opt/local-path-provisioner"] + }, + { + "node":"linode", + "paths":["/opt/local-path-provisioner"] + } + ] + } + setup: |- + #!/bin/sh + set -eu + mkdir -m 0777 -p "$VOL_DIR" + teardown: |- + #!/bin/sh + set -eu + rm -rf "$VOL_DIR" + helperPod.yaml: |- + apiVersion: v1 + kind: Pod + metadata: + name: helper-pod + spec: + priorityClassName: system-node-critical + nodeSelector: + kubernetes.io/hostname: linode + tolerations: + - key: node.kubernetes.io/disk-pressure + operator: Exists + effect: NoSchedule + - key: dedicated + operator: Equal + value: network + effect: PreferNoSchedule + containers: + - name: helper-pod + image: busybox + imagePullPolicy: IfNotPresent +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: local-path-provisioner-linode + namespace: local-path-storage +spec: + replicas: 1 + selector: + matchLabels: + app: local-path-provisioner-linode + template: + metadata: + labels: + app: local-path-provisioner-linode + spec: + serviceAccountName: local-path-provisioner-service-account + nodeSelector: + kubernetes.io/hostname: linode + tolerations: + - key: dedicated + operator: Equal + value: network + effect: PreferNoSchedule + containers: + - name: local-path-provisioner + image: rancher/local-path-provisioner:v0.0.31 + imagePullPolicy: IfNotPresent + command: + - local-path-provisioner + - --debug + - start + - --config + - /etc/config/config.json + - --provisioner-name + - rancher.io/local-path-linode + - --configmap-name + - local-path-config-linode + volumeMounts: + - name: config-volume + mountPath: /etc/config/ + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CONFIG_MOUNT_PATH + value: /etc/config/ + - name: KUBERNETES_SERVICE_HOST + value: "10.10.0.2" + - name: KUBERNETES_SERVICE_PORT + value: "6443" + volumes: + - name: config-volume + configMap: + name: local-path-config-linode +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-path-linode +provisioner: rancher.io/local-path-linode +volumeBindingMode: WaitForFirstConsumer +reclaimPolicy: Delete From b55ec826c909fe19bafd853c14bcc39290aa31af Mon Sep 17 00:00:00 2001 From: devops Date: Sat, 21 Nov 2026 16:24:16 -0500 Subject: [PATCH 65/88] apps(osint): place stateless CPU workers on the amd64 linode node news-scraper, news-summarizer, ingester and nats were hard-pinned to siriussec (the ThinkPad, on a 15 W USB-C supply that brownouts under load). Replace the hostname pin with: * nodeSelector kubernetes.io/arch=amd64 (keeps them off the arm64 rpi) * preferred nodeAffinity weight 100 for kubernetes.io/hostname=linode still falling back to siriussec if linode is down. No PVCs, images, resources or taints touched. --- apps/base/osint/ingester-deployment.yaml | 16 +++++++++++++++- apps/base/osint/nats-deployment.yaml | 16 +++++++++++++++- apps/base/osint/news-scraper-deployment.yaml | 16 +++++++++++++++- apps/base/osint/news-summarizer-deployment.yaml | 16 +++++++++++++++- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 796f336..cfd2ce6 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -19,8 +19,22 @@ spec: - key: dedicated operator: Exists effect: PreferNoSchedule + affinity: + nodeAffinity: + # Prefer the amd64 worker (linode) for these stateless CPU loops so + # they stop drawing on the 15 W-powered ThinkPad. Preferred, not + # required: if linode is absent they still schedule on siriussec. + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - linode + # keeps these off the arm64 rpi (some of these images are amd64-only) nodeSelector: - kubernetes.io/hostname: siriussec + kubernetes.io/arch: amd64 containers: - name: ingester image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be diff --git a/apps/base/osint/nats-deployment.yaml b/apps/base/osint/nats-deployment.yaml index 772b076..52fe659 100644 --- a/apps/base/osint/nats-deployment.yaml +++ b/apps/base/osint/nats-deployment.yaml @@ -19,8 +19,22 @@ spec: - key: dedicated operator: Exists effect: PreferNoSchedule + affinity: + nodeAffinity: + # Prefer the amd64 worker (linode) for these stateless CPU loops so + # they stop drawing on the 15 W-powered ThinkPad. Preferred, not + # required: if linode is absent they still schedule on siriussec. + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - linode + # keeps these off the arm64 rpi (some of these images are amd64-only) nodeSelector: - kubernetes.io/hostname: siriussec + kubernetes.io/arch: amd64 containers: - name: nats image: forgejo.siriusdevops.com/sirius/nats:2.10 diff --git a/apps/base/osint/news-scraper-deployment.yaml b/apps/base/osint/news-scraper-deployment.yaml index c211ee8..22cfd07 100644 --- a/apps/base/osint/news-scraper-deployment.yaml +++ b/apps/base/osint/news-scraper-deployment.yaml @@ -19,8 +19,22 @@ spec: - key: dedicated operator: Exists effect: PreferNoSchedule + affinity: + nodeAffinity: + # Prefer the amd64 worker (linode) for these stateless CPU loops so + # they stop drawing on the 15 W-powered ThinkPad. Preferred, not + # required: if linode is absent they still schedule on siriussec. + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - linode + # keeps these off the arm64 rpi (some of these images are amd64-only) nodeSelector: - kubernetes.io/hostname: siriussec + kubernetes.io/arch: amd64 containers: - name: news-scraper image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-58f71f5b4520 diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml index 163b6d0..647fdc8 100644 --- a/apps/base/osint/news-summarizer-deployment.yaml +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -19,8 +19,22 @@ spec: - key: dedicated operator: Exists effect: PreferNoSchedule + affinity: + nodeAffinity: + # Prefer the amd64 worker (linode) for these stateless CPU loops so + # they stop drawing on the 15 W-powered ThinkPad. Preferred, not + # required: if linode is absent they still schedule on siriussec. + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - linode + # keeps these off the arm64 rpi (some of these images are amd64-only) nodeSelector: - kubernetes.io/hostname: siriussec + kubernetes.io/arch: amd64 containers: - name: news-summarizer image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0 From c2cdc2d5c1807f73df504316c93e95e22d61110d Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 16:47:03 -0500 Subject: [PATCH 66/88] apps(osint): move osint-db onto a linode-local PVC osint-db (TimescaleDB+PostGIS) moves from siriussec's local-path PV to a new 15Gi local-path-linode claim restored from a pg_dump (44,120,765 bytes, sha256 d74afa6d...30da). The Deployment gets a required linode nodeAffinity plus an amd64 arch selector; the old osint-pgdata claim and its PV are left untouched so rollback is one revert of claimName + scheduling. --- apps/base/osint/kustomization.yaml | 1 + apps/base/osint/postgres-deployment.yaml | 16 ++++++++++++++-- apps/base/osint/postgres-pvc-linode.yaml | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 apps/base/osint/postgres-pvc-linode.yaml diff --git a/apps/base/osint/kustomization.yaml b/apps/base/osint/kustomization.yaml index e002a5c..02eb79c 100644 --- a/apps/base/osint/kustomization.yaml +++ b/apps/base/osint/kustomization.yaml @@ -4,6 +4,7 @@ resources: - namespace.yaml - configmap.yaml - postgres-pvc.yaml + - postgres-pvc-linode.yaml - postgres-deployment.yaml - postgres-service.yaml - nats-deployment.yaml diff --git a/apps/base/osint/postgres-deployment.yaml b/apps/base/osint/postgres-deployment.yaml index 936873b..2c84ab7 100644 --- a/apps/base/osint/postgres-deployment.yaml +++ b/apps/base/osint/postgres-deployment.yaml @@ -27,8 +27,20 @@ spec: - key: dedicated operator: Exists effect: PreferNoSchedule + # Local-path volume: the claim (osint-pgdata-linode) is pinned to linode by + # its PV, so the pod must be too. arch selector documents why: the image is + # amd64-only, as on every other node this can land on. nodeSelector: - kubernetes.io/hostname: siriussec + kubernetes.io/arch: amd64 + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - linode containers: - name: postgres image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2 @@ -79,4 +91,4 @@ spec: volumes: - name: pgdata persistentVolumeClaim: - claimName: osint-pgdata + claimName: osint-pgdata-linode diff --git a/apps/base/osint/postgres-pvc-linode.yaml b/apps/base/osint/postgres-pvc-linode.yaml new file mode 100644 index 0000000..a7dc02b --- /dev/null +++ b/apps/base/osint/postgres-pvc-linode.yaml @@ -0,0 +1,16 @@ +# Post-migration home for osint-db: a linode-local volume. +# Kept separate from postgres-pvc.yaml (osint-pgdata, on siriussec) so a +# rollback is one revert of the Deployment's claimName; the old claim and its +# PV stay untouched and Bound. +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: osint-pgdata-linode + namespace: osint +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path-linode + resources: + requests: + storage: 15Gi From e63c14641da49fcfea0d1de5b874b0a5bb593992 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 17:13:54 -0500 Subject: [PATCH 67/88] apps(osint): pg image r3 for timescaledb 2.32.1 on PG 16.16 PG 16.16 added the PortalDrop() "cannot drop portal" check that TimescaleDB <=2.32.0 trips from the background scheduler, so every policy job (refresh/compression/retention/job history) failed with SQLSTATE 24000 although CALL run_job() worked (timescale/timescaledb#11038, fixed in 2.32.1). Rebuilt apps/base/osint/pg-image/Dockerfile with: - base postgres:16.16-bookworm (was floating 16-bookworm) - timescaledb-2-postgresql-16 / -2-loader-postgresql-16 pinned to 2.32.1~debian12-1616 (built against PG 16.16) Pushed as amd64-c48788d4b614-r3 (digest sha256:b2bdc093...), verified by a throwaway restore of a fresh pg_dump: extension 2.32.0 -> ALTER EXTENSION UPDATE 2.32.1 -> all 12 jobs Success with real last_successful_finish and no portal errors. --- apps/base/osint/README.md | 16 +++++++++++++--- apps/base/osint/pg-image/Dockerfile | 23 ++++++++++++++++++----- apps/base/osint/postgres-deployment.yaml | 2 +- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index eb44b51..a3f838d 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -8,7 +8,7 @@ instead of a host Docker container on the Pi. | Deployment | Image | Purpose | |---|---|---| -| `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi | +| `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3` | TimescaleDB 2.32.1 + PostGIS 3 on Postgres 16.16, `local-path-linode` PVC `osint-pgdata-linode` 15 Gi | | `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) | | `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-915f6cbe25be` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations | | `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres | @@ -56,13 +56,23 @@ docker build -f pg-image/Dockerfile -t 127.0.0.1:3000/sirius/osint-das ``` `pg-image/Dockerfile` is the cluster copy of `Dockerfile.pg`. **It pins -`postgres:16-bookworm`**: the upstream file's bare `postgres:16` now resolves to -Debian trixie, whose `postgresql-16-postgis-3` (3.7.0+pgdg13) fails to load +`postgres:16.16-bookworm`**: the upstream file's bare `postgres:16` now resolves +to Debian trixie, whose `postgresql-16-postgis-3` (3.7.0+pgdg13) fails to load against PG 16.15 with `undefined symbol: heap_datum_check` — `CREATE EXTENSION postgis` crashes the server. On bookworm (`+pgdg12`) PostGIS 3.7 loads and `create_hypertable()` works. Port the one-line base-image pin upstream when the Pi stack is next rebuilt. +It also pins the TimescaleDB packages to `2.32.1~debian12-1616` (the `-1616` +suffix = built against PG 16.16) and the base image to the 16.16 minor. PG +16.16 added the `PortalDrop()` "cannot drop portal while it is being set up" +check that TimescaleDB <=2.32.0 trips in its background-worker path, so every +policy job failed with SQLSTATE 24000 while `CALL run_job()` worked +(timescale/timescaledb#11038, fixed in 2.31.2/2.32.1). Never unpin either half: +a pg minor bump without a matching TimescaleDB build reintroduces the failure. +`-r3` is that build. After a pod recreate the extension itself still has to be +moved: `ALTER EXTENSION timescaledb UPDATE TO '2.32.1'`. + ## Secrets (never in git) ```bash diff --git a/apps/base/osint/pg-image/Dockerfile b/apps/base/osint/pg-image/Dockerfile index faa014e..fa7acbc 100644 --- a/apps/base/osint/pg-image/Dockerfile +++ b/apps/base/osint/pg-image/Dockerfile @@ -1,19 +1,32 @@ # Cluster build of the OSINT Postgres image (amd64). # # Identical to `Dockerfile.pg` in sirius/osint-dashboard EXCEPT the base image -# is pinned to bookworm. The upstream `FROM postgres:16` now resolves to Debian -# trixie, where postgresql-16-postgis-3 (3.7.0+pgdg13) fails to load against -# PostgreSQL 16.15: +# is pinned to Debian bookworm AND to the 16.16 minor. The upstream file's bare +# `FROM postgres:16` now resolves to Debian trixie, where +# postgresql-16-postgis-3 (3.7.0+pgdg13) fails to load against PostgreSQL 16.15: # could not load library "/usr/lib/postgresql/16/lib/postgis-3.so": # undefined symbol: heap_datum_check # On bookworm (+pgdg12) both extensions load and create_hypertable() works. -FROM postgres:16-bookworm +# +# PostgreSQL minor and the TimescaleDB package build MUST match. TimescaleDB +# publishes one .so per PG minor (the packagecloud suffix `-1616` means built +# against 16.16). PostgreSQL 16.16/17.12/18.7 added the PortalDrop() "while it +# is being set up" check, which the <=2.32.0 background scheduler trips on, so +# every policy job fails with `cannot drop portal ""` (timescale#11038, fixed +# in 2.32.1). Both halves are pinned here so a rebuild cannot silently drift +# back onto a mismatched pair. +# +# Resulting versions: PostgreSQL 16.16, postgis 3.7.0, timescaledb 2.32.1. +# After a pod recreate run `ALTER EXTENSION timescaledb UPDATE TO '2.32.1'`. +FROM postgres:16.16-bookworm RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl gnupg lsb-release && \ curl -fsSL https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash && \ apt-get update && apt-get install -y --no-install-recommends \ - postgresql-16-postgis-3 timescaledb-2-postgresql-16 && \ + postgresql-16-postgis-3 \ + timescaledb-2-postgresql-16=2.32.1~debian12-1616 \ + timescaledb-2-loader-postgresql-16=2.32.1~debian12-1616 && \ mkdir -p /etc/postgresql/16/main/conf.d && \ echo "shared_preload_libraries = 'timescaledb'" > /etc/postgresql/16/main/conf.d/timescaledb.conf && \ rm -rf /var/lib/apt/lists/* diff --git a/apps/base/osint/postgres-deployment.yaml b/apps/base/osint/postgres-deployment.yaml index 2c84ab7..3f37a54 100644 --- a/apps/base/osint/postgres-deployment.yaml +++ b/apps/base/osint/postgres-deployment.yaml @@ -43,7 +43,7 @@ spec: - linode containers: - name: postgres - image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2 + image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3 imagePullPolicy: IfNotPresent args: - -c From f326735a8b37548313d52b366539025bafec3191 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 17:42:10 -0500 Subject: [PATCH 68/88] apps(osint): pin app to amd64-54897b49bc57 + ADS-B idle watch env osint-dashboard#68: the ADSB refresh loop persisted aircraft only for connected browser viewports, so aircraft_positions stalled whenever nobody had the map open. The new image sweeps the chokepoint presets while idle; this commit pins it and sets ADSB_REFRESH_INTERVAL/ADSB_WATCH_* explicitly instead of relying on app defaults. ingester/camera keep amd64-915f6cbe25be (no loop change there); pinning the ingester would restart it for nothing. --- apps/base/osint/app-deployment.yaml | 4 ++-- apps/base/osint/configmap.yaml | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/base/osint/app-deployment.yaml b/apps/base/osint/app-deployment.yaml index 93ebf7f..99acbc1 100644 --- a/apps/base/osint/app-deployment.yaml +++ b/apps/base/osint/app-deployment.yaml @@ -24,7 +24,7 @@ spec: initContainers: # Wait for Postgres before alembic runs (the entrypoint migrates). - name: wait-for-db - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-54897b49bc57 imagePullPolicy: IfNotPresent command: - python @@ -42,7 +42,7 @@ spec: sys.exit("postgres did not become reachable in 300s") containers: - name: app - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-54897b49bc57 imagePullPolicy: IfNotPresent ports: - containerPort: 8000 diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index bdc0e70..fa58991 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -36,6 +36,15 @@ data: VESSELAPI_IN_APP: "0" VESSELAPI_IN_INGEST: "1" + # ── ADS-B refresh (osint-app `_adsb_refresh_loop`) ────────────────────── + # The loop polls ADSB.lol for each connected browser viewport. With no tab + # open it used to persist nothing, and aircraft_positions stalled for a day + # (max(ts) frozen 2026-11-20 04:58 -> 2026-11-21) while USGS/news kept + # ingesting. While idle it now sweeps the chokepoint presets instead. + ADSB_REFRESH_INTERVAL: "8" + ADSB_WATCH_ENABLED: "1" + ADSB_WATCH_INTERVAL: "30" + # ── camera discovery service ──────────────────────────────────────────── CAMERA_SOURCE_URLS: "" CAMERA_SCRAPE_INTERVAL: "3600" From f0a82f85deac01e5fe105047bcaffb0d603926fb Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 17:58:33 -0500 Subject: [PATCH 69/88] apps(osint): set PGDATABASE=osint_data on osint-db deploy/osint-db logged 'FATAL: database "osint" does not exist' straight after it became ready (2026-11-21 22:15:15): any bare `psql -U osint` / `pg_dump -U osint` inside the pod defaults the database to the user name. PGDATABASE makes osint_data the default so ops commands cannot aim at a database that does not exist. Probes already pass -d osint_data. --- apps/base/osint/postgres-deployment.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/base/osint/postgres-deployment.yaml b/apps/base/osint/postgres-deployment.yaml index 3f37a54..dd4a051 100644 --- a/apps/base/osint/postgres-deployment.yaml +++ b/apps/base/osint/postgres-deployment.yaml @@ -60,6 +60,12 @@ spec: value: osint - name: POSTGRES_DB value: osint_data + # Bare `psql`/`pg_dump -U osint` inside this pod would otherwise + # default the database to the USER name and log + # `FATAL: database "osint" does not exist` (seen 2026-11-21 22:15 + # on deploy/osint-db). PGDATABASE makes the correct db the default. + - name: PGDATABASE + value: osint_data - name: PGDATA value: /var/lib/postgresql/data/pgdata - name: POSTGRES_PASSWORD From 1e9253c147c26bfdfa21cfb0f39218c6622e2afe Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 18:15:51 -0500 Subject: [PATCH 70/88] apps(osint): pin ingester to amd64-fc0cd41b7aa4 (GDELT 429 backoff) osint-dashboard#69: drop the pointless https->http retry on 429, add a doubling backoff (300s -> 1800s, Retry-After honoured) and log one line per cycle instead of a traceback. Ingester only; app/camera keep their tags. --- apps/base/osint/ingester-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index cfd2ce6..6b29c07 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -37,7 +37,7 @@ spec: kubernetes.io/arch: amd64 containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fc0cd41b7aa4 imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: From 0e5ba18377d15c6a0c25504a1b86d76b349bcc26 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 21 Nov 2026 18:39:28 -0500 Subject: [PATCH 71/88] apps(osint): pin ingester to amd64-76035535bcb2 (GDELT 15-min GKG bulk ingest) --- apps/base/osint/ingester-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/osint/ingester-deployment.yaml b/apps/base/osint/ingester-deployment.yaml index 6b29c07..d0e8682 100644 --- a/apps/base/osint/ingester-deployment.yaml +++ b/apps/base/osint/ingester-deployment.yaml @@ -37,7 +37,7 @@ spec: kubernetes.io/arch: amd64 containers: - name: ingester - image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-fc0cd41b7aa4 + image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-76035535bcb2 imagePullPolicy: IfNotPresent command: ["python", "app/run_ingester.py"] envFrom: From 930752152e07e5c149cdadefa38f05bf7862c802 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sun, 22 Nov 2026 00:32:31 -0500 Subject: [PATCH 72/88] apps(metabase): deploy Metabase (WireGuard-only :8085) with CNPG app DB - apps/base/metabase: namespace, CNPG Cluster pg (5Gi local-path, siriussec), Metabase Deployment v0.65.6.3 (1.5G heap, no PVC), Service, hostname-less HTTPRoute on the dedicated metabase Gateway - infrastructure/networking/internal: new Gateway metabase on port 8085 (own RouteConfiguration, so it cannot merge with Grafana's bare route) - host firewall: 8085 in siriussec nft set + rpi ufw guard --- apps/base/metabase/cluster.yaml | 38 +++++++++ apps/base/metabase/deployment.yaml | 83 +++++++++++++++++++ apps/base/metabase/httproute.yaml | 25 ++++++ apps/base/metabase/kustomization.yaml | 10 +++ apps/base/metabase/namespace.yaml | 6 ++ apps/base/metabase/service.yaml | 14 ++++ apps/home/kustomization.yaml | 1 + .../networking/internal/gateway-metabase.yaml | 31 +++++++ .../internal/host-firewall/README.md | 7 +- .../internal-gw-firewall.service | 4 +- .../host-firewall/rpi-ufw-internal-gw.sh | 7 +- .../host-firewall/siriussec-internal-gw.nft | 12 +-- .../networking/internal/kustomization.yaml | 1 + 13 files changed, 225 insertions(+), 14 deletions(-) create mode 100644 apps/base/metabase/cluster.yaml create mode 100644 apps/base/metabase/deployment.yaml create mode 100644 apps/base/metabase/httproute.yaml create mode 100644 apps/base/metabase/kustomization.yaml create mode 100644 apps/base/metabase/namespace.yaml create mode 100644 apps/base/metabase/service.yaml create mode 100644 infrastructure/networking/internal/gateway-metabase.yaml diff --git a/apps/base/metabase/cluster.yaml b/apps/base/metabase/cluster.yaml new file mode 100644 index 0000000..18d404d --- /dev/null +++ b/apps/base/metabase/cluster.yaml @@ -0,0 +1,38 @@ +# Metabase's application database (its own metadata only: users, dashboards, +# questions, saved queries — never the data it queries). +# +# Same shape as every other CNPG cluster in this repo: one instance, local-path +# on siriussec, no superuser access. `bootstrap.initdb.secret` names the +# out-of-band Secret `metabase/pg-app` (kubernetes.io/basic-auth, username +# `metabase` — CNPG requires the secret's username to equal `owner`). The +# operator materialises `pg-app` with the same credentials for the Deployment. +# +# No barman ObjectStore yet: the other clusters get WAL archiving to Garage via +# the CNPG-I Barman Cloud plugin; this evaluation instance is deliberately left +# with no archive until Lance keeps it (follow-up card, not a silent gap). +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: pg + namespace: metabase +spec: + instances: 1 + imageName: ghcr.io/cloudnative-pg/postgresql:16 + storage: + size: 5Gi + storageClass: local-path + affinity: + nodeSelector: + kubernetes.io/hostname: siriussec + bootstrap: + initdb: + database: metabase + owner: metabase + secret: + name: pg-app + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi diff --git a/apps/base/metabase/deployment.yaml b/apps/base/metabase/deployment.yaml new file mode 100644 index 0000000..d7c6fd2 --- /dev/null +++ b/apps/base/metabase/deployment.yaml @@ -0,0 +1,83 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: metabase + namespace: metabase +spec: + replicas: 1 + selector: + matchLabels: + app: metabase + template: + metadata: + labels: + app: metabase + spec: + # Siriussec is the only gateway node (upstream Envoy has to reach the + # backend pod on the same node), and the CNPG primary is pinned here too. + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + containers: + - name: metabase + # Pinned release tag (2026-11-20, multi-arch). Never latest/nightly: + # Metabase auto-migrates its app DB on start, so an unpinned tag turns + # a pod restart into a schema upgrade. + image: metabase/metabase:v0.65.6.3 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 3000 + env: + # One JVM, 1.5 GiB heap, container limit 2 GiB. The laptop is on a + # marginal USB-C supply; a 2 GiB heap here is what starved it in the + # past (see references/laptop-node-power.md). + - name: JAVA_OPTS + value: "-Xmx1536m" + # All state lives in Postgres (no H2 file, no PVC), so the pod is + # disposable and `strategy: Recreate` is unnecessary. + - name: MB_DB_TYPE + value: postgres + - name: MB_DB_HOST + value: pg-rw.metabase.svc.cluster.local + - name: MB_DB_PORT + value: "5432" + - name: MB_DB_DBNAME + value: metabase + - name: MB_DB_USER + valueFrom: + secretKeyRef: + name: pg-app + key: username + - name: MB_DB_PASS + valueFrom: + secretKeyRef: + name: pg-app + key: password + readinessProbe: + httpGet: + path: /api/health + port: 3000 + # The JVM takes ~30-60 s to migrate/bootstrap its app DB. + initialDelaySeconds: 20 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 6 + livenessProbe: + httpGet: + path: /api/health + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 30 + timeoutSeconds: 10 + failureThreshold: 3 + resources: + requests: + cpu: 250m + memory: 1Gi + limits: + cpu: "2" + memory: 2Gi diff --git a/apps/base/metabase/httproute.yaml b/apps/base/metabase/httproute.yaml new file mode 100644 index 0000000..1ad119e --- /dev/null +++ b/apps/base/metabase/httproute.yaml @@ -0,0 +1,25 @@ +# Internal only, and deliberately HOSTNAME-LESS: it answers on the bare WireGuard +# address http://10.10.0.2:8085/ for every Host header. Phones cannot edit +# /etc/hosts, so a hostname would make the evaluation unusable on mobile. +# +# parentRefs is the dedicated `metabase` Gateway (infrastructure/networking/ +# internal/gateway-metabase.yaml), NOT the shared `internal` one: Cilium merges +# every hostname-less route of a Gateway into one weighted route, so sharing a +# Gateway with Grafana would serve both services on both ports at random. +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: metabase + namespace: metabase +spec: + parentRefs: + - name: metabase + namespace: internal + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: metabase + port: 3000 diff --git a/apps/base/metabase/kustomization.yaml b/apps/base/metabase/kustomization.yaml new file mode 100644 index 0000000..aaf2916 --- /dev/null +++ b/apps/base/metabase/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + # Secret metabase/pg-app (kubernetes.io/basic-auth) is created out of band + # before this Cluster applies — CNPG's initdb reads it. + - cluster.yaml + - deployment.yaml + - service.yaml + - httproute.yaml diff --git a/apps/base/metabase/namespace.yaml b/apps/base/metabase/namespace.yaml new file mode 100644 index 0000000..763c274 --- /dev/null +++ b/apps/base/metabase/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: metabase + labels: + app.kubernetes.io/part-of: metabase diff --git a/apps/base/metabase/service.yaml b/apps/base/metabase/service.yaml new file mode 100644 index 0000000..89f8d74 --- /dev/null +++ b/apps/base/metabase/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: metabase + namespace: metabase +spec: + type: ClusterIP + selector: + app: metabase + ports: + - name: http + port: 3000 + targetPort: 3000 + protocol: TCP diff --git a/apps/home/kustomization.yaml b/apps/home/kustomization.yaml index 1a08fad..18845da 100644 --- a/apps/home/kustomization.yaml +++ b/apps/home/kustomization.yaml @@ -6,3 +6,4 @@ resources: - ../base/piedmont - ../base/sirius-growth - ../base/osint + - ../base/metabase diff --git a/infrastructure/networking/internal/gateway-metabase.yaml b/infrastructure/networking/internal/gateway-metabase.yaml new file mode 100644 index 0000000..1eedd8b --- /dev/null +++ b/infrastructure/networking/internal/gateway-metabase.yaml @@ -0,0 +1,31 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: metabase + namespace: internal + labels: + dedicated: network + annotations: + # Why a second Gateway instead of a second listener on `internal`: + # Cilium renders one RouteConfiguration per Gateway shared by all its + # listeners, so a hostname-less route on any listener of `internal` would + # merge with Grafana's into one 50/50 weighted route. Its own Gateway gives + # it its own RouteConfiguration. + sirius.dev/purpose: bare-IP listener for Metabase (WireGuard only) +spec: + gatewayClassName: cilium + listeners: + - name: http-internal + protocol: HTTP + # PORT MUST BE FREE ON *EVERY* NODE THAT RUNS cilium-envoy (siriussec + # 10.10.0.2 is the only `gateway=true` node today). Cilium binds + # 0.0.0.0: hostNetwork, so a port held by anything else on a gateway + # node makes xDS reject the listener there ("cannot bind '0.0.0.0:': + # Address already in use") and restart-loops that node's Envoy — which + # fronts the public ingress. Verified free 2026-11-22: + # `ss -lntH "sport = :8085" | wc -l` = 0 on siriussec. + # 8080 (public), 8081 (Grafana), 8084 (Hubble UI) are taken. + port: 8085 + allowedRoutes: + namespaces: + from: All diff --git a/infrastructure/networking/internal/host-firewall/README.md b/infrastructure/networking/internal/host-firewall/README.md index b8a037b..e03fd2e 100644 --- a/infrastructure/networking/internal/host-firewall/README.md +++ b/infrastructure/networking/internal/host-firewall/README.md @@ -21,7 +21,8 @@ exactly one node. | siriussec (10.10.0.2) — **load bearing** | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` | | rpi (10.10.0.1) — **inert guard** | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` | -Effective policy for `:8081` (Grafana) and `:8084` (Hubble UI): +Effective policy for `:8081` (Grafana), `:8084` (Hubble UI) and `:8085` +(Metabase): **accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a new internal listener port is a LAN exposure until it is added here. The @@ -56,7 +57,7 @@ Verify: # the drop counter non-zero after a LAN request nft list table inet internal_gw # rpi -ufw status | grep -E '8081|8084' +ufw status | grep -E '8081|8084|8085' ``` Negative test from the LAN must be a timeout (DROP), never 200: @@ -70,4 +71,4 @@ When a new internal listener port is added, add it to the `tcp dport { … }` se in `siriussec-internal-gw.nft` and to `PORTS` in `rpi-ufw-internal-gw.sh` (which inserts one deny for the port plus mesh and pod-CIDR allows above the LAN catch-all), then reinstall both and re-run the two negative tests above with the -new port. +new port. \ No newline at end of file diff --git a/infrastructure/networking/internal/host-firewall/internal-gw-firewall.service b/infrastructure/networking/internal/host-firewall/internal-gw-firewall.service index 1d60425..c46890b 100644 --- a/infrastructure/networking/internal/host-firewall/internal-gw-firewall.service +++ b/infrastructure/networking/internal/host-firewall/internal-gw-firewall.service @@ -4,7 +4,7 @@ # Flux-managed); the file lives in git at # infrastructure/networking/internal/host-firewall/. [Unit] -Description=Restrict the internal Gateway listeners (8081, 8082) to WireGuard +Description=Restrict the internal Gateway listeners (8081, 8084, 8085) to WireGuard After=network-online.target Wants=network-online.target @@ -14,4 +14,4 @@ ExecStart=/usr/sbin/nft -f /etc/nftables.d/internal-gw.nft RemainAfterExit=yes [Install] -WantedBy=multi-user.target +WantedBy=multi-user.target \ No newline at end of file diff --git a/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh b/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh index 9c02418..fcbba69 100644 --- a/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh +++ b/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh @@ -6,14 +6,15 @@ # Final order per port: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest. # # Ports: 8081 = Grafana (`internal` Gateway listener http-internal), -# 8084 = Hubble UI (`internal` Gateway listener hubble-ui). +# 8084 = Hubble UI (`internal` Gateway listener hubble-ui), +# 8085 = Metabase (`metabase` Gateway listener http-internal). # Add a new internal listener port to PORTS; the loop is idempotent, so # re-running after a port is already firewalled only adds what is missing. # # Run as root on rpi (192.168.1.125). set -euo pipefail -PORTS="${PORTS:-8081 8084}" +PORTS="${PORTS:-8081 8084 8085}" for port in $PORTS; do if ufw status | grep -q "${port}/tcp"; then @@ -28,4 +29,4 @@ for port in $PORTS; do echo "$port rules installed:" ufw status | grep "${port}/tcp" || true -done +done \ No newline at end of file diff --git a/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft b/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft index 9f51db6..16a9801 100644 --- a/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft +++ b/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft @@ -1,6 +1,6 @@ #!/usr/sbin/nft -f -# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana) and 8084 -# (Hubble UI). +# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana), 8084 +# (Hubble UI) and 8085 (Metabase). # # Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the # internal listeners are open on the LAN interface the moment the Gateway is @@ -22,13 +22,13 @@ table inet internal_gw { type filter hook input priority filter; policy accept; # local process / kubelet probes - tcp dport { 8081, 8084 } iifname "lo" counter accept + tcp dport { 8081, 8084, 8085 } iifname "lo" counter accept # WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes) # and the pod network (in-cluster scrapers, probes) - tcp dport { 8081, 8084 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept + tcp dport { 8081, 8084, 8085 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept # everything else: LAN, tailscale, public - tcp dport { 8081, 8084 } counter drop + tcp dport { 8081, 8084, 8085 } counter drop } -} +} \ No newline at end of file diff --git a/infrastructure/networking/internal/kustomization.yaml b/infrastructure/networking/internal/kustomization.yaml index 60f44f2..d6d0f1e 100644 --- a/infrastructure/networking/internal/kustomization.yaml +++ b/infrastructure/networking/internal/kustomization.yaml @@ -4,3 +4,4 @@ resources: - namespace.yaml - gateway.yaml - gateway-hubble-ui.yaml + - gateway-metabase.yaml From 7f7f806616b5c885504ccf9322f365f4c500b461 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sun, 22 Nov 2026 02:15:56 -0500 Subject: [PATCH 73/88] apps(farrisilk): lab replica stack (Odoo 18 + plain Postgres + Metabase) on :8086/:8087 Odoo 18 (dated tag 18.0-20261112) on a plain postgres:16 container, not CNPG: the client runs bare Postgres on a Proxmox VM and this namespace mirrors that shape. Odoo's initContainer installs base,web once, applies the read-only BI grants/revokes and sets the admin login from a Secret. Metabase gets its own state in the same Postgres (db metabase) with a 1Gi heap and MB_ENCRYPTION_SECRET_KEY. Two bare-IP Gateways (8086 odoo, 8087 metabase) in ns internal, each with its own RouteConfiguration. Host firewall (nft on siriussec, ufw on rpi) carries 8086/8087 and was installed before the Gateways were pushed. --- apps/base/farrisilk/httproute.yaml | 44 +++ apps/base/farrisilk/kustomization.yaml | 19 ++ apps/base/farrisilk/metabase.yaml | 106 +++++++ apps/base/farrisilk/namespace.yaml | 7 + apps/base/farrisilk/odoo-init.yaml | 164 +++++++++++ apps/base/farrisilk/odoo.yaml | 258 ++++++++++++++++++ apps/base/farrisilk/postgres-init.yaml | 67 +++++ apps/base/farrisilk/postgres.yaml | 140 ++++++++++ apps/home/kustomization.yaml | 1 + .../internal/gateway-farrisilk-metabase.yaml | 26 ++ .../internal/gateway-farrisilk-odoo.yaml | 31 +++ .../host-firewall/rpi-ufw-internal-gw.sh | 6 +- .../host-firewall/siriussec-internal-gw.nft | 9 +- .../networking/internal/kustomization.yaml | 2 + 14 files changed, 874 insertions(+), 6 deletions(-) create mode 100644 apps/base/farrisilk/httproute.yaml create mode 100644 apps/base/farrisilk/kustomization.yaml create mode 100644 apps/base/farrisilk/metabase.yaml create mode 100644 apps/base/farrisilk/namespace.yaml create mode 100644 apps/base/farrisilk/odoo-init.yaml create mode 100644 apps/base/farrisilk/odoo.yaml create mode 100644 apps/base/farrisilk/postgres-init.yaml create mode 100644 apps/base/farrisilk/postgres.yaml create mode 100644 infrastructure/networking/internal/gateway-farrisilk-metabase.yaml create mode 100644 infrastructure/networking/internal/gateway-farrisilk-odoo.yaml diff --git a/apps/base/farrisilk/httproute.yaml b/apps/base/farrisilk/httproute.yaml new file mode 100644 index 0000000..5c99157 --- /dev/null +++ b/apps/base/farrisilk/httproute.yaml @@ -0,0 +1,44 @@ +# Two separate HTTPRoutes and two separate Gateways, on purpose. +# +# A hostname-less route answers on the bare WireGuard address +# (http://10.10.0.2:8086/ and :8087/) for ANY Host header, because a phone +# cannot edit /etc/hosts. Cilium renders ONE RouteConfiguration per Gateway and +# merges every hostname-less route in it into a single weighted route, so two +# services sharing one Gateway serve each other's traffic at random regardless +# of listener port. Hence gateway-farrisilk-odoo.yaml (8086) and +# gateway-farrisilk-metabase.yaml (8087) in infrastructure/networking/internal/. +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: odoo + namespace: farrisilk +spec: + parentRefs: + - name: farrisilk-odoo + namespace: internal + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: odoo + port: 8069 +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: metabase + namespace: farrisilk +spec: + parentRefs: + - name: farrisilk-metabase + namespace: internal + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: metabase + port: 3000 diff --git a/apps/base/farrisilk/kustomization.yaml b/apps/base/farrisilk/kustomization.yaml new file mode 100644 index 0000000..5a9d57e --- /dev/null +++ b/apps/base/farrisilk/kustomization.yaml @@ -0,0 +1,19 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + # Secrets are created out of band, before this Kustomization applies: + # farrisilk/pg-app basic-auth, postgres superuser + # farrisilk/pg-users odoo/metabase/metabase_ro role passwords + # farrisilk/odoo-config admin_passwd (database master password) + # farrisilk/odoo-admin email, password (web admin login) + # farrisilk/metabase-admin email, password (Metabase's own login) + # farrisilk/metabase-data-source-creds username=metabase_ro + password + # farrisilk/metabase-secret-key MB_ENCRYPTION_SECRET_KEY + # None of them appear in git; they are not managed (or pruned) by Flux. + - postgres-init.yaml + - postgres.yaml + - odoo-init.yaml + - odoo.yaml + - metabase.yaml + - httproute.yaml diff --git a/apps/base/farrisilk/metabase.yaml b/apps/base/farrisilk/metabase.yaml new file mode 100644 index 0000000..4cc9330 --- /dev/null +++ b/apps/base/farrisilk/metabase.yaml @@ -0,0 +1,106 @@ +# Metabase for the lab replica — its own state in the SAME plain Postgres +# (database `metabase`), one data source: `farrisilk odoo` as `metabase_ro`. +# +# This is a SECOND instance next to the evaluation one in namespace `metabase`. +# The laptop is on a marginal USB-C supply, so it does not repeat that +# instance's 1.5 GiB heap: 1 GiB heap, 2 GiB container limit. +# +# MB_ENCRYPTION_SECRET_KEY is set here on purpose. Without it Metabase encrypts +# stored data-source passwords with a key derived from its own default, so a +# copy of the app DB is enough to read them. The key lives in Secret +# `farrisilk/metabase-secret-key` and must stay stable for the life of the app +# DB — rotating it makes every stored datasource password undecryptable. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: metabase + namespace: farrisilk +spec: + replicas: 1 + selector: + matchLabels: + app: metabase + template: + metadata: + labels: + app: metabase + app.kubernetes.io/part-of: farrisilk + spec: + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + containers: + - name: metabase + image: metabase/metabase:v0.65.6.3 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 3000 + env: + - name: JAVA_OPTS + value: "-Xmx1024m" + - name: MB_DB_TYPE + value: postgres + - name: MB_DB_HOST + value: pg.farrisilk.svc.cluster.local + - name: MB_DB_PORT + value: "5432" + - name: MB_DB_DBNAME + value: metabase + - name: MB_DB_USER + value: metabase + - name: MB_DB_PASS + valueFrom: + secretKeyRef: + name: pg-users + key: metabase_password + - name: MB_ENCRYPTION_SECRET_KEY + valueFrom: + secretKeyRef: + name: metabase-secret-key + key: MB_ENCRYPTION_SECRET_KEY + - name: MB_JETTY_PORT + value: "3000" + - name: TZ + value: America/Los_Angeles + readinessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 20 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 6 + livenessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 120 + periodSeconds: 30 + timeoutSeconds: 10 + failureThreshold: 3 + resources: + requests: + cpu: 250m + memory: 1Gi + limits: + cpu: "2" + memory: 2Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: metabase + namespace: farrisilk +spec: + type: ClusterIP + selector: + app: metabase + ports: + - name: http + port: 3000 + targetPort: http + protocol: TCP diff --git a/apps/base/farrisilk/namespace.yaml b/apps/base/farrisilk/namespace.yaml new file mode 100644 index 0000000..d06ff54 --- /dev/null +++ b/apps/base/farrisilk/namespace.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: farrisilk + labels: + app.kubernetes.io/part-of: farrisilk + sirius.dev/purpose: lab-replica-of-client-stack diff --git a/apps/base/farrisilk/odoo-init.yaml b/apps/base/farrisilk/odoo-init.yaml new file mode 100644 index 0000000..2b64e84 --- /dev/null +++ b/apps/base/farrisilk/odoo-init.yaml @@ -0,0 +1,164 @@ +# Odoo provisioning, run as an initContainer on every pod start — idempotent by +# construction, so a restart never re-initialises a live database. +# +# 1. wait for Postgres +# 2. if the `farrisilk` database has no tables: `odoo -i base,web +# --without-demo=all --stop-after-init` (the "init once" step, done by the +# pod rather than by a separate Job so there is exactly one thing to wait +# on and no ordering race between a Job and the Deployment) +# 3. CREATE EXTENSION unaccent, as the database owner +# 4. (re)apply the read-only BI grants over every table Odoo just created, +# including revoking the tables that carry credentials +# 5. set the admin login/password from Secret `farrisilk/odoo-admin` +# +# Step 4 runs unconditionally, not only on first install: it is what picks up +# tables added by a later module install (`-i`/`-u` from /mnt/extra-addons), and +# `ALTER DEFAULT PRIVILEGES` alone does not cover tables created before the +# grant. Nothing here writes a credential to stdout. +apiVersion: v1 +kind: ConfigMap +metadata: + name: odoo-init + namespace: farrisilk +data: + init_db.py: | + #!/usr/bin/env python3 + """Idempotent first-run provisioning of the Farrisilk lab Odoo database.""" + import os + import subprocess + import sys + import time + + import psycopg2 + + HOST = os.environ["DB_HOST"] + PORT = int(os.environ.get("DB_PORT", "5432")) + SUPER_USER = os.environ["PG_SUPERUSER"] + SUPER_PW = os.environ["PG_SUPERPASS"] + DB = os.environ.get("ODOO_DB_NAME", "farrisilk") + CONF = "/etc/odoo-runtime/odoo.conf" + ADMIN_LOGIN = os.environ["ODOO_ADMIN_LOGIN"] + ADMIN_PASSWORD = os.environ["ODOO_ADMIN_PASSWORD"] + + # Tables that hold credentials looking like data. `ir_config_parameter` is + # the one the card calls out (API keys/tokens for integrations); the rest + # are the same class of column. `res_users` is deliberately NOT in this + # list: it carries a password *hash* only, and Metabase needs it for user + # counts. Everything found by inspection at runtime is added and logged. + CREDENTIAL_TABLES = [ + "ir_config_parameter", + "ir_mail_server", + "fetchmail_server", + "res_users_apikeys", + "payment_provider", + "res_users_identitycheck", + ] + + def connect(dbname, user, password): + conn = psycopg2.connect( + host=HOST, port=PORT, dbname=dbname, user=user, password=password, + connect_timeout=10, + ) + conn.autocommit = True + return conn + + def wait_for_pg(): + for _ in range(90): + try: + connect("postgres", SUPER_USER, SUPER_PW).close() + return + except psycopg2.Error: + time.sleep(2) + sys.exit("postgres unreachable") + + def tables(cur): + cur.execute( + "select table_name from information_schema.tables " + "where table_schema = 'public' and table_type = 'BASE TABLE'" + ) + return {r[0] for r in cur.fetchall()} + + def run(cmd, **kw): + print("+ " + " ".join(cmd), flush=True) + subprocess.run(cmd, check=True, **kw) + + wait_for_pg() + + conn = connect("postgres", SUPER_USER, SUPER_PW) + cur = conn.cursor() + cur.execute("select 1 from pg_database where datname = %s", (DB,)) + exists = cur.fetchone() is not None + conn.close() + + have_tables = False + if exists: + dconn = connect(DB, SUPER_USER, SUPER_PW) + dcur = dconn.cursor() + have_tables = bool(tables(dcur)) + dconn.close() + + if not have_tables: + print(f"== initialising {DB}: base,web (no demo data) ==", flush=True) + run(["odoo", "-c", CONF, "-d", DB, "-i", "base,web", + "--without-demo=all", "--stop-after-init", "--no-http"]) + else: + print(f"== {DB} already initialised: skipping -i base ==", flush=True) + + # unaccent as the database owner (trusted extension in PG16). Odoo uses it + # for accent-insensitive search in the web client. + oconn = connect(DB, "odoo", os.environ["ODOO_DB_PASSWORD"]) + ocur = oconn.cursor() + ocur.execute("CREATE EXTENSION IF NOT EXISTS unaccent") + ocur.execute("select extname, extowner::regrole::text from pg_extension where extname = 'unaccent'") + print("unaccent:", ocur.fetchone(), flush=True) + oconn.close() + + # Read-only BI grants + credential-table revokes. + gconn = connect(DB, SUPER_USER, SUPER_PW) + gcur = gconn.cursor() + gcur.execute("GRANT USAGE ON SCHEMA public TO metabase_ro") + gcur.execute("GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro") + gcur.execute( + "ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public " + "GRANT SELECT ON TABLES TO metabase_ro" + ) + present = tables(gcur) + revoked = sorted({t for t in CREDENTIAL_TABLES if t in present}) + # Inspect rather than assume the static list is complete: anything whose + # columns look like credentials is added to the revoke set (logged below). + gcur.execute( + "select distinct table_name from information_schema.columns " + "where table_schema = 'public' and (" + " column_name ~ '(^|_)(password|secret|token)($|_)' or " + " column_name ~ '(api_key|access_key|private_key)'" + ") and table_name not in ('res_users', 'res_partner')" + ) + for (t,) in gcur.fetchall(): + if t in present and t not in revoked: + revoked.append(t) + revoked = sorted(revoked) + for t in revoked: + gcur.execute("REVOKE SELECT ON public.%s FROM metabase_ro" % t) + gcur.execute( + "select table_name from information_schema.table_privileges " + "where grantee = 'metabase_ro' and privilege_type = 'SELECT' " + "and table_schema = 'public' order by 1" + ) + readable = len(gcur.fetchall()) + gconn.close() + print(f"metabase_ro: SELECT granted on {readable} tables; " + f"revoked on {revoked}", flush=True) + + # Admin login/password from Secret farrisilk/odoo-admin. `odoo shell` is + # the supported way to set a res.users password without hand-rolling a + # pbkdf2 hash. Re-writing the same value on every start is harmless. + payload = ( + "u = env.ref('base.user_admin')\n" + f"u.write({{'login': {ADMIN_LOGIN!r}, 'password': {ADMIN_PASSWORD!r}}})\n" + "env.cr.commit()\n" + "print('admin uid', u.id, 'login', u.login)\n" + ) + run(["odoo", "shell", "-c", CONF, "-d", DB, "--no-http", + "--shell-interface=python"], input=payload, text=True) + + print("== provisioning complete ==", flush=True) diff --git a/apps/base/farrisilk/odoo.yaml b/apps/base/farrisilk/odoo.yaml new file mode 100644 index 0000000..2e89fcb --- /dev/null +++ b/apps/base/farrisilk/odoo.yaml @@ -0,0 +1,258 @@ +# Odoo 18 — the application half of the Farrisilk lab replica. +# +# Image is pinned to the DATED build, never `18.0`/`latest`: Odoo auto-migrates +# its database schema on start, so a floating tag turns a pod restart into an +# unplanned upgrade of a database you may be auditing. +# +# This image already ships wkhtmltopdf 0.12.6.1 (patched Qt) at +# /usr/local/bin/wkhtmltopdf, so PDF reports/ invoices render without a derived +# image. Verified 2026-11-22 — see README. +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: odoo-data + namespace: farrisilk +spec: + accessModes: [ReadWriteOnce] + storageClassName: local-path + resources: + requests: + storage: 10Gi +--- +# Empty by default. This is where the client's custom modules are copied in +# (`kubectl cp ./module farrisilk/:/mnt/extra-addons/...`), which is +# why it is a PVC and not an emptyDir: a module installed from here must survive +# a pod restart, or the modules table and the addons path disagree and Odoo +# refuses to start the affected modules. +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: odoo-extra-addons + namespace: farrisilk +spec: + accessModes: [ReadWriteOnce] + storageClassName: local-path + resources: + requests: + storage: 5Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: odoo + namespace: farrisilk +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: odoo + template: + metadata: + labels: + app: odoo + app.kubernetes.io/part-of: farrisilk + spec: + # Envoy has to reach the backend on the same node it serves from, and the + # filestore PVC is local-path (siriussec-only anyway). + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + initContainers: + # Odoo has no env-var support for db_password, so the config file is + # rendered from the ConfigMap template + the Secret on every pod start + # into an emptyDir. Runs as root only to fix PVC ownership (the image + # user is uid 100 / gid 101 and local-path hands out root-owned dirs). + - name: render-config + image: odoo:18.0-20261112 + imagePullPolicy: IfNotPresent + securityContext: + runAsUser: 0 + command: + - /bin/sh + - -ec + - | + mkdir -p /mnt/extra-addons /var/lib/odoo /etc/odoo-runtime + chown -R 100:101 /var/lib/odoo /mnt/extra-addons + chmod 0755 /mnt/extra-addons + umask 077 + cat > /etc/odoo-runtime/odoo.conf < hostNetwork, so +# the host firewall (infrastructure/networking/internal/host-firewall/) must be +# installed BEFORE this is pushed; otherwise the listener is open on the LAN the +# moment it is programmed. +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: farrisilk-odoo + namespace: internal + labels: + dedicated: network + annotations: + sirius.dev/purpose: bare-IP listener for the Farrisilk lab Odoo (WireGuard only) +spec: + gatewayClassName: cilium + listeners: + - name: http-internal + protocol: HTTP + # Verified free 2026-11-22: `ss -lntH "sport = :8086" | wc -l` = 0 on + # siriussec. Taken: 8080 public, 8081 Grafana, 8084 Hubble, 8085 Metabase. + port: 8086 + allowedRoutes: + namespaces: + from: All diff --git a/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh b/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh index fcbba69..16dfe94 100644 --- a/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh +++ b/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh @@ -7,14 +7,16 @@ # # Ports: 8081 = Grafana (`internal` Gateway listener http-internal), # 8084 = Hubble UI (`internal` Gateway listener hubble-ui), -# 8085 = Metabase (`metabase` Gateway listener http-internal). +# 8085 = Metabase (`metabase` Gateway listener http-internal), +# 8086 = Farrisilk lab Odoo (`farrisilk-odoo` Gateway), +# 8087 = Farrisilk lab Metabase (`farrisilk-metabase` Gateway). # Add a new internal listener port to PORTS; the loop is idempotent, so # re-running after a port is already firewalled only adds what is missing. # # Run as root on rpi (192.168.1.125). set -euo pipefail -PORTS="${PORTS:-8081 8084 8085}" +PORTS="${PORTS:-8081 8084 8085 8086 8087}" for port in $PORTS; do if ufw status | grep -q "${port}/tcp"; then diff --git a/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft b/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft index 16a9801..046a53c 100644 --- a/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft +++ b/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft @@ -1,6 +1,7 @@ #!/usr/sbin/nft -f # Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana), 8084 -# (Hubble UI) and 8085 (Metabase). +# (Hubble UI), 8085 (Metabase) and 8086/8087 (Farrisilk lab replica: Odoo, +# Metabase). # # Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the # internal listeners are open on the LAN interface the moment the Gateway is @@ -22,13 +23,13 @@ table inet internal_gw { type filter hook input priority filter; policy accept; # local process / kubelet probes - tcp dport { 8081, 8084, 8085 } iifname "lo" counter accept + tcp dport { 8081, 8084, 8085, 8086, 8087 } iifname "lo" counter accept # WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes) # and the pod network (in-cluster scrapers, probes) - tcp dport { 8081, 8084, 8085 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept + tcp dport { 8081, 8084, 8085, 8086, 8087 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept # everything else: LAN, tailscale, public - tcp dport { 8081, 8084, 8085 } counter drop + tcp dport { 8081, 8084, 8085, 8086, 8087 } counter drop } } \ No newline at end of file diff --git a/infrastructure/networking/internal/kustomization.yaml b/infrastructure/networking/internal/kustomization.yaml index d6d0f1e..fc93e64 100644 --- a/infrastructure/networking/internal/kustomization.yaml +++ b/infrastructure/networking/internal/kustomization.yaml @@ -5,3 +5,5 @@ resources: - gateway.yaml - gateway-hubble-ui.yaml - gateway-metabase.yaml + - gateway-farrisilk-odoo.yaml + - gateway-farrisilk-metabase.yaml From 4891694f6f2db466c717073b5a4667f8cfd4a78d Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sun, 22 Nov 2026 02:25:09 -0500 Subject: [PATCH 74/88] apps(farrisilk): name Odoo's database `odoo` (align with the BI grants + Metabase source) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The card's build section names db `odoo` (owner odoo) and points Metabase at pg.../odoo, while its Odoo config line said db_name=farrisilk — the two cannot both hold. Aligned on `odoo`: db_name/dbfilter in odoo.conf and the init script's ODOO_DB_NAME. The renamed database kept its data (partner 7, product template 1, base+web+product installed). --- apps/base/farrisilk/odoo-init.yaml | 4 ++-- apps/base/farrisilk/odoo.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/base/farrisilk/odoo-init.yaml b/apps/base/farrisilk/odoo-init.yaml index 2b64e84..147202c 100644 --- a/apps/base/farrisilk/odoo-init.yaml +++ b/apps/base/farrisilk/odoo-init.yaml @@ -2,7 +2,7 @@ # construction, so a restart never re-initialises a live database. # # 1. wait for Postgres -# 2. if the `farrisilk` database has no tables: `odoo -i base,web +# 2. if the `odoo` database has no tables: `odoo -i base,web # --without-demo=all --stop-after-init` (the "init once" step, done by the # pod rather than by a separate Job so there is exactly one thing to wait # on and no ordering race between a Job and the Deployment) @@ -35,7 +35,7 @@ data: PORT = int(os.environ.get("DB_PORT", "5432")) SUPER_USER = os.environ["PG_SUPERUSER"] SUPER_PW = os.environ["PG_SUPERPASS"] - DB = os.environ.get("ODOO_DB_NAME", "farrisilk") + DB = os.environ.get("ODOO_DB_NAME", "odoo") CONF = "/etc/odoo-runtime/odoo.conf" ADMIN_LOGIN = os.environ["ODOO_ADMIN_LOGIN"] ADMIN_PASSWORD = os.environ["ODOO_ADMIN_PASSWORD"] diff --git a/apps/base/farrisilk/odoo.yaml b/apps/base/farrisilk/odoo.yaml index 2e89fcb..4c93f0f 100644 --- a/apps/base/farrisilk/odoo.yaml +++ b/apps/base/farrisilk/odoo.yaml @@ -88,10 +88,10 @@ spec: data_dir = /var/lib/odoo db_host = ${DB_HOST} db_port = ${DB_PORT} - db_name = farrisilk + db_name = odoo db_user = odoo db_password = ${ODOO_DB_PASSWORD} - dbfilter = ^farrisilk\$ + dbfilter = ^odoo\$ list_db = False proxy_mode = True workers = 0 @@ -138,7 +138,7 @@ spec: - name: DB_PORT value: "5432" - name: ODOO_DB_NAME - value: farrisilk + value: odoo - name: PG_SUPERUSER valueFrom: secretKeyRef: From f658bfabe977fb4ee4733349718dfbfc8d532d22 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sun, 22 Nov 2026 02:28:56 -0500 Subject: [PATCH 75/88] apps(farrisilk): close the metabase_ro schema-CREATE hole + README metabase_ro could create tables in public: default_transaction_read_only is a role default the role can lift (SET ... = off), and PG16 keeps CREATE on schema public for PUBLIC when the database was created by a non-superuser (Odoo creates its own). Revoke CREATE from PUBLIC and ALL from metabase_ro, grant USAGE only, in both the first-boot script and the per-start grant pass. README documents the stack, list_db/workers=0 rationale, module loading, filestore, the DB-only backup gap (filestore is not covered; follow-up t_8bdd3708) and the Shopify blank. --- apps/base/farrisilk/README.md | 278 +++++++++++++++++++++++++ apps/base/farrisilk/odoo-init.yaml | 8 + apps/base/farrisilk/postgres-init.yaml | 5 + 3 files changed, 291 insertions(+) create mode 100644 apps/base/farrisilk/README.md diff --git a/apps/base/farrisilk/README.md b/apps/base/farrisilk/README.md new file mode 100644 index 0000000..99bdc1d --- /dev/null +++ b/apps/base/farrisilk/README.md @@ -0,0 +1,278 @@ +# farrisilk — lab replica of the Farrisilk client stack + +A **development/audit sandbox** shaped like Farrisilk Inc.'s production stack — +not a copy of their traffic, and not their architecture. Odoo 18 + a plain +PostgreSQL + Metabase, WireGuard-only, in namespace `farrisilk`. + +| Service | URL over WireGuard | Bare IP? | Notes | +|---|---|---|---| +| Odoo 18 | `http://10.10.0.2:8086/` | yes, any `Host` | `http://10.10.0.2:8086/web/login` | +| Metabase | `http://10.10.0.2:8087/` | yes, any `Host` | secondary instance, 1 GiB heap | +| PostgreSQL | `pg.farrisilk.svc.cluster.local:5432` | in-cluster only | no NodePort, no gateway | + +`10.10.0.2` is siriussec, the only node labelled `gateway=true` (the only node +running `cilium-envoy`). Nothing here has a public hostname, a tunnel entry or a +DNS record — same posture as the `:8085` evaluation Metabase. + +## What is deliberately *not* like the homelab + +The client runs **Odoo 18 + PostgreSQL on two on-prem Proxmox VMs**, plus +Metabase and a Shopify integration containerised alongside. No Kubernetes. +This namespace is our sandbox for developing and auditing against *their* shape: + +- **Postgres is a plain container (`postgres:16`) on one `local-path` volume, + not a CloudNativePG Cluster.** No operator, no replicas, no WAL archive — + because the client's database is a bare VM install. Do not "improve" it into + CNPG; that would test an architecture they do not run. +- **Odoo runs `workers=0`** (see below), where production may run several. +- **One Postgres, two databases**: `odoo` (the Odoo database, owner and app role + `odoo`) and `metabase` (Metabase's own application DB, owner `metabase`). + +## Layout + +| Object | File | +|---|---| +| Namespace | `namespace.yaml` | +| `pg` Deployment + Service + `pg-data` PVC (10Gi) | `postgres.yaml` | +| First-boot roles/databases (`/docker-entrypoint-initdb.d`) | `postgres-init.yaml` | +| Odoo Deployment/Service, `odoo-data` (10Gi) + `odoo-extra-addons` (5Gi) PVCs | `odoo.yaml` | +| Idempotent Odoo provisioning script (initContainer) | `odoo-init.yaml` | +| Metabase Deployment + Service | `metabase.yaml` | +| Two hostname-less HTTPRoutes | `httproute.yaml` | + +Gateways live with the other internal listeners: +`infrastructure/networking/internal/gateway-farrisilk-odoo.yaml` (8086) and +`gateway-farrisilk-metabase.yaml` (8087). **Each bare-IP service gets its own +Gateway**: Cilium renders one RouteConfiguration per Gateway and merges every +hostname-less route inside it into a weighted route, so two services sharing a +Gateway answer for each other at random. The host firewall +(`infrastructure/networking/internal/host-firewall/`, nft on siriussec + ufw on +rpi) carries 8086/8087 and was installed *before* the Gateways were pushed, so +there was never a window where Envoy's `0.0.0.0` bind was open on the LAN. + +## First boot / how the database comes up + +The `odoo` Deployment's initContainers do all provisioning — there is no +separate Job to race against: + +1. `render-config` renders `/etc/odoo-runtime/odoo.conf` from the ConfigMap + values plus Secret `pg-users`, and fixes PVC ownership (uid 100 / gid 101). + Odoo has no env-var support for `db_password`, hence the rendering step. +2. `init-db` (script in `odoo-init.yaml`): + - waits for Postgres; + - **if the `odoo` database has no tables**, runs + `odoo -d odoo -i base,web --without-demo=all --stop-after-init`; + - `CREATE EXTENSION IF NOT EXISTS unaccent` as the database owner; + - (re)applies the read-only BI grants and credential-table revokes, every + start, so tables added by a later module install are covered too; + - sets the admin login/password from Secret `farrisilk/odoo-admin` via + `odoo shell`. + +Restarting the pod is safe and visibly idempotent: +`== odoo already initialised: skipping -i base ==`. + +Metabase's own tables are created by Metabase in database `metabase` on first +start; nothing pre-creates them. + +## Custom modules (the client has some) + +Copy the module directory into the `odoo-extra-addons` PVC, then install it +through the ORM: + +```bash +POD=$(kubectl -n farrisilk get pod -l app=odoo -o name | head -1) +kubectl -n farrisilk cp ./client_module "${POD#pod/}:/mnt/extra-addons/client_module" -c odoo +kubectl -n farrisilk exec -i deploy/odoo -c odoo -- \ + odoo shell -c /etc/odoo-runtime/odoo.conf -d odoo --no-http --shell-interface=python <<'EOF' +m = env['ir.module.module'].search([('name', '=', 'client_module')]) +m.button_immediate_install() +env.cr.commit() +print(m.state) +EOF +``` + +Then `kubectl -n farrisilk delete pod -l app=odoo` once, so `init-db` re-applies +the `metabase_ro` SELECT grants to the tables the module just created (grants +are re-applied on every pod start; `ALTER DEFAULT PRIVILEGES` covers tables +created after the grant but not before it). + +The PVC is why a module survives a restart: an installed module whose directory +disappears from `addons_path` makes Odoo refuse to load it. + +`/mnt/enterprise-addons` is an **emptyDir**, already on `addons_path` and +unused. Whether the client actually runs Enterprise is still an open question; +drop an EE addons tree there (or turn it into a PVC) only once that is answered. + +## `list_db=False`, and how to flip it + +`list_db = False` mirrors the client's production posture: the database manager +(`/web/database/manager`, database create/duplicate/drop) is not reachable from +a browser. `dbfilter = ^odoo$` pins the served database. + +For development work that needs the database manager (e.g. duplicating the DB +before a risky migration), change the `list_db` line in the `render-config` +script in `odoo.yaml` to `True`, push, let Flux roll the pod — do not +`kubectl exec`-edit the rendered config, it is re-rendered on every start. +Flip it back afterwards: with `list_db=True` and `proxy_mode=True` the manager +is reachable by anyone on the WireGuard mesh. + +## Why `workers=0` (and what production needs) + +`workers=0` runs Odoo as a single process (threaded). It is the honest setting +for a one-user lab replica on a laptop: multi-worker needs its own gevent/bus +port and much more RAM. + +**Production shape**: `workers = (2 × cores) + 1`, capped by available RAM at +roughly **512 MB per worker** (plus the 1.5 GiB hard limit for the main +process), with `max_cron_threads` counted separately. + +Going multi-worker here requires exposing the **gevent/bus port 8072** through +its own Gateway listener *and* its own host-firewall entry — a plain +`workers=N` without 8072 breaks longpolling/bus (the web client silently loses +notifications). 8072 is deliberately not opened while `workers=0`. + +## Filestore (where attachments actually live) + +`data_dir = /var/lib/odoo` on PVC `odoo-data`, so attachment bytes live at +`/var/lib/odoo/filestore/odoo/<2-char>/` inside the Odoo pod +(`ir_attachment.store_fname` = `<2-char>/`). Verified: an `ir.attachment` +created over XML-RPC appears as a 697-byte file at exactly that path. + +**The DB is not the filestore.** `ir_attachment` rows hold metadata; the bytes +are files. A database-only restore comes back looking healthy and every +attachment, image and rendered artefact is gone. + +## Backups — the gap, stated plainly + +There are **no backups of this stack in the cluster**, and none are being added +by this card. + +The client's practice is a **cron-driven `pg_dump` of the database only** — no +barman/PITR, no filestore copy. The replica mirrors that *shape*; the follow-up +card (`t_8bdd3708`) proves the failure mode deliberately rather than hiding it. +Two consequences to keep in mind while auditing: + +1. `pg_dump` of `odoo` + `metabase` reproduces Odoo's database and Metabase's + questions/dashboards. It does **not** reproduce `/var/lib/odoo/filestore`. +2. A DB-only restore therefore produces an Odoo instance where the attachment + list is intact and every download 404s. That is the client's real exposure + too, if their cron really copies only the DB. + +## PDF reports + +The pinned image (`odoo:18.0-20261112`) ships **`wkhtmltopdf 0.12.6.1 (with +patched qt)`** at `/usr/local/bin/wkhtmltopdf`, so no derived image is needed +and PDF rendering is not a gap here. Proven end-to-end over the gateway: +`GET /report/pdf/product.report_pricelist/1` → `200`, `application/pdf`, +16 032 bytes, 13 pages. + +If a future image drops wkhtmltopdf, the fix is a derived image +`FROM odoo:18.0-` installing the *patched-qt* build (the Debian +`wkhtmltopdf` package is not patched and renders headers/footers badly), built +`runs-on: docker-amd64` and pinned by tag in `odoo.yaml`. + +## Metabase (secondary instance) + +- Image `metabase/metabase:v0.65.6.3`, `JAVA_OPTS=-Xmx1024m`, container limit + 2 GiB — this is a *second* Metabase next to the `metabase` namespace + evaluation instance and does not repeat its 1.5 GiB heap on this laptop. +- State lives in the same Postgres, database `metabase`, user `metabase`. +- **`MB_ENCRYPTION_SECRET_KEY` is set** (Secret `farrisilk/metabase-secret-key`) + so stored data-source passwords are not encrypted with Metabase's default key. + Keep it stable: rotating it makes every stored datasource password + undecryptable. +- Set up entirely through the API (`/api/session/properties` → `POST /api/setup` + → `POST /api/session` → `POST /api/database` → `sync_schema`), one data source: + **`farrisilk odoo`** → `pg.farrisilk.svc.cluster.local:5432/odoo` as + `metabase_ro`. +- Metabase has no per-database "read-only" switch for PostgreSQL sources; the + read-only guarantee here is the **role**, which is stronger (see below). + +### The read-only BI role (practice, not shortcut) + +`metabase_ro` is created by `postgres-init.yaml` and re-secured by +`odoo-init.yaml` on every pod start: + +```sql +-- role-level defaults +ALTER ROLE metabase_ro SET default_transaction_read_only = on; +ALTER ROLE metabase_ro SET statement_timeout = '60s'; +ALTER ROLE metabase_ro SET idle_in_transaction_session_timeout = '60s'; +-- CONNECTION LIMIT 10 +-- database/schema +REVOKE CREATE ON SCHEMA public FROM PUBLIC; -- PG16 keeps PUBLIC=CREATE when +REVOKE ALL ON SCHEMA public FROM metabase_ro; -- the DB was made by a non-superuser +GRANT USAGE ON SCHEMA public TO metabase_ro; +GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro; +ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public + GRANT SELECT ON TABLES TO metabase_ro; +``` + +Why the schema revokes matter: `default_transaction_read_only` is a role +*default*, and the role may lift it with `SET default_transaction_read_only = +off`. Without the revoke, `metabase_ro` could create tables in `public` +(observed on 2026-11-22 — this was a real gap, now closed). With it, a create +fails twice over: read-only transaction, and `permission denied for schema +public`. + +Credential-bearing tables are **revoked, not just unqueried**. The set is +computed at every start (a static list plus anything whose columns match +`password|secret|token|api_key|private_key`) and logged: + +``` +metabase_ro: SELECT granted on 224 tables; revoked on +['auth_totp_wizard','change_password_own','fetchmail_server','iap_account', + 'ir_attachment','ir_config_parameter','ir_mail_server','mail_guest', + 'res_config_settings','res_groups','res_users_apikeys','res_users_identitycheck'] +``` + +`ir_config_parameter` is the one that matters most (integration API keys and +tokens). `res_users` stays readable on purpose — it carries only a password +*hash* and Metabase needs it for user counts. + +## Secrets (out of band, in the cluster only) + +Created before the Kustomization applies; never in git, never printed: + +| Secret | Keys | Used by | +|---|---|---| +| `pg-app` | `username`=postgres, `password` | Postgres bootstrap superuser | +| `pg-users` | `odoo_password`, `metabase_password`, `metabase_ro_password` | role passwords (initdb + workloads) | +| `odoo-config` | `admin_passwd` | Odoo database master password | +| `odoo-admin` | `email`, `password` | Odoo web admin login (uid 2) | +| `metabase-admin` | `email`, `password` | Metabase's own login (**email**, no username) | +| `metabase-data-source-creds` | `username`=metabase_ro, `password` | the `farrisilk odoo` data source | +| `metabase-secret-key` | `MB_ENCRYPTION_SECRET_KEY` | Metabase at-rest encryption | + +## Shopify — integration surface only, blocked on client credentials + +Shopify is SaaS: **there is nothing to deploy in this cluster**, and this +namespace deliberately contains no stub service and no unauthenticated webhook +listener. What the replica needs before a connector can exist: + +1. **Store domain** (e.g. `.myshopify.com`) and the store's plan — Lance + has not seen the store. +2. **Admin API access token** with scopes for the resources the connector + syncs (products/orders/inventory read-write; webhooks write), created in the + store's custom-app settings. Stored as a Secret, never in git. +3. The **Odoo Shopify connector module** (the client has custom modules; the + QSIT/Shopify connector is a separate module) copied into + `/mnt/extra-addons` — see "Custom modules". +4. **Webhook path through the ingress.** Shopify must POST to a reachable + HTTPS URL. This namespace is WireGuard-only, so a webhook path needs a + public hostname + tunnel entry *and* HMAC verification — a decision that + must be made explicitly for the replica, not inherited from prod. + +Status: **blocked on client credentials** (store domain + Admin API token + +the connector module). Until then the Odoo side stays unconfigured on purpose. + +## Deviations from the card, recorded + +- The card's build section names db `odoo` (owner `odoo`), §4 grants on + database `odoo`, and Metabase's data source is `…:5432/odoo`, while the Odoo + config bullet said `db_name=farrisilk`. Those cannot both hold; the stack is + aligned on **`odoo`** (`db_name`, `dbfilter=^odoo$`, `ODOO_DB_NAME`, the BI + grants and the Metabase source all say `odoo`). +- `base,web` are installed (not `base` alone) so `/web/login` serves a real web + client. `product` was installed to create the acceptance product; a fresh + build installs `base,web` only. diff --git a/apps/base/farrisilk/odoo-init.yaml b/apps/base/farrisilk/odoo-init.yaml index 147202c..47cf718 100644 --- a/apps/base/farrisilk/odoo-init.yaml +++ b/apps/base/farrisilk/odoo-init.yaml @@ -116,6 +116,14 @@ data: # Read-only BI grants + credential-table revokes. gconn = connect(DB, SUPER_USER, SUPER_PW) gcur = gconn.cursor() + # PostgreSQL 16 leaves CREATE on schema public granted to PUBLIC in a + # database created by a NON-SUPERUSER (Odoo creates its own database as + # `odoo`), so `default_transaction_read_only` is the only thing stopping + # metabase_ro from creating tables — and a role may lift its own default + # with `SET default_transaction_read_only = off`. Privileges are the real + # guard: PUBLIC loses CREATE, metabase_ro gets USAGE only. + gcur.execute("REVOKE CREATE ON SCHEMA public FROM PUBLIC") + gcur.execute("REVOKE ALL ON SCHEMA public FROM metabase_ro") gcur.execute("GRANT USAGE ON SCHEMA public TO metabase_ro") gcur.execute("GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro") gcur.execute( diff --git a/apps/base/farrisilk/postgres-init.yaml b/apps/base/farrisilk/postgres-init.yaml index ea4d5de..652de5e 100644 --- a/apps/base/farrisilk/postgres-init.yaml +++ b/apps/base/farrisilk/postgres-init.yaml @@ -61,6 +61,11 @@ data: # Schema-level setup in the (still empty) odoo database. Table grants and # the credential-table revokes are (re)applied by the odoo initContainer. psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname odoo <<'EOSQL' + -- Odoo creates the `odoo` role's tables later; PUBLIC must not keep CREATE + -- on the public schema (PG16 keeps it when the database was made by a + -- non-superuser), or the "read-only" BI role can create tables after + -- lifting its own default_transaction_read_only. + REVOKE CREATE ON SCHEMA public FROM PUBLIC; GRANT USAGE ON SCHEMA public TO metabase_ro; ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public GRANT SELECT ON TABLES TO metabase_ro; From 03fb50c3d7d3e62d02164f6876111830832dfefe Mon Sep 17 00:00:00 2001 From: devops Date: Sun, 22 Nov 2026 02:38:35 -0500 Subject: [PATCH 76/88] apps(farrisilk): client-shaped nightly pg_dump cron + 14d retention on a 10Gi PVC --- apps/base/farrisilk/backup.yaml | 169 +++++++++++++++++++++++++ apps/base/farrisilk/kustomization.yaml | 1 + 2 files changed, 170 insertions(+) create mode 100644 apps/base/farrisilk/backup.yaml diff --git a/apps/base/farrisilk/backup.yaml b/apps/base/farrisilk/backup.yaml new file mode 100644 index 0000000..2e2567c --- /dev/null +++ b/apps/base/farrisilk/backup.yaml @@ -0,0 +1,169 @@ +# Nightly logical backup of BOTH databases — the *standard shape* of the client's +# stated practice (bash script on cron that dumps the database). +# +# This is NOT a copy of the client's script: theirs has not been seen yet +# (Week 3 read-only audit item). It implements what Lance described — a nightly +# `pg_dump` per database, timestamped files, an age-based retention sweep and a +# per-run log line — and nothing more. +# +# Deliberately absent, because the client's method has none of it: +# - WAL archiving / PITR -> worst-case RPO is 24 h (see README) +# - filestore (attachment bytes)-> the dump carries rows, not files (see README) +# - off-box copy -> dumps live on siriussec's local-path disk +# (the Garage S3 API at http://10.10.0.1:3900 is reachable from a pod, but it +# needs a bucket + credentials that are not part of this namespace; copy is +# therefore NOT implemented and backups die with the node — on purpose, so +# the replica shows the real exposure.) +# +# No RBAC: the default ServiceAccount, with its token not even mounted. This pod +# talks to Postgres over the ClusterIP Service and writes to its own PVC. +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: backup-data + namespace: farrisilk + labels: + app.kubernetes.io/part-of: farrisilk +spec: + accessModes: [ReadWriteOnce] + storageClassName: local-path + resources: + requests: + storage: 10Gi +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: pg-backup-script + namespace: farrisilk + labels: + app.kubernetes.io/part-of: farrisilk +data: + backup.sh: | + #!/bin/sh + # Nightly pg_dump -Fc of each database + age-based retention. + # Exit non-zero if ANY dump fails or comes back with an empty TOC, so a + # broken backup turns the Job red instead of silently succeeding. + set -eu + : "${PGHOST:=pg}" + : "${PGPORT:=5432}" + : "${PGUSER:=postgres}" + : "${BACKUP_DIR:=/backups}" + : "${RETENTION_DAYS:=14}" + DATABASES="${DATABASES:-odoo metabase}" + + ts="$(date -u +%Y%m%dT%H%M%SZ)" + mkdir -p "$BACKUP_DIR" + run_start="$(date +%s)" + rc=0 + + echo "backup: run start ts=$ts databases='$DATABASES' retention=${RETENTION_DAYS}d dir=$BACKUP_DIR" + for db in $DATABASES; do + file="$BACKUP_DIR/$db-$ts.dump" + start="$(date +%s)" + if pg_dump -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$db" -Fc -f "$file"; then + dur=$(( $(date +%s) - start )) + bytes="$(stat -c %s "$file")" + toc="$(pg_restore --list "$file" | wc -l)" + if [ "$toc" -gt 0 ]; then + echo "backup: ok db=$db file=$db-$ts.dump size=${bytes}B toc_entries=$toc duration=${dur}s" + else + echo "backup: FAIL db=$db file=$db-$ts.dump empty archive TOC" >&2 + rc=1 + fi + else + echo "backup: FAIL db=$db pg_dump did not complete" >&2 + rc=1 + fi + done + + echo "backup: retention sweep, deleting *.dump older than ${RETENTION_DAYS} days" + find "$BACKUP_DIR" -maxdepth 1 -type f -name '*.dump' -mtime +"$RETENTION_DAYS" -print -delete || rc=1 + + echo "backup: run complete rc=$rc total=$(( $(date +%s) - run_start ))s dumps_on_disk=$(ls -1 "$BACKUP_DIR"/*.dump 2>/dev/null | wc -l)" + exit "$rc" +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: pg-backup + namespace: farrisilk + labels: + app.kubernetes.io/part-of: farrisilk +spec: + # 03:17 America/Los_Angeles — one run per night, off the hour so it does not + # collide with Odoo's own cron threads or Metabase syncs at :00. + schedule: "17 3 * * *" + timeZone: America/Los_Angeles + concurrencyPolicy: Forbid + startingDeadlineSeconds: 600 + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + backoffLimit: 1 + activeDeadlineSeconds: 1800 + template: + metadata: + labels: + app: pg-backup + app.kubernetes.io/part-of: farrisilk + spec: + restartPolicy: Never + automountServiceAccountToken: false + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + # local-path hands out root-owned directories; the pod writes the PVC + # as root. It only runs pg_dump + pg_restore (client tools) and find. + securityContext: + runAsUser: 0 + runAsGroup: 0 + containers: + - name: pg-dump + image: postgres:16 + imagePullPolicy: IfNotPresent + command: ["/bin/sh", "/opt/backup/backup.sh"] + env: + - name: PGHOST + value: pg.farrisilk.svc.cluster.local + - name: PGPORT + value: "5432" + - name: PGUSER + valueFrom: + secretKeyRef: + name: pg-app + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: pg-app + key: password + - name: RETENTION_DAYS + value: "14" + - name: TZ + value: America/Los_Angeles + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 512Mi + volumeMounts: + - name: backups + mountPath: /backups + - name: script + mountPath: /opt/backup + readOnly: true + volumes: + - name: backups + persistentVolumeClaim: + claimName: backup-data + - name: script + configMap: + name: pg-backup-script + defaultMode: 0555 diff --git a/apps/base/farrisilk/kustomization.yaml b/apps/base/farrisilk/kustomization.yaml index 5a9d57e..ed462db 100644 --- a/apps/base/farrisilk/kustomization.yaml +++ b/apps/base/farrisilk/kustomization.yaml @@ -16,4 +16,5 @@ resources: - odoo-init.yaml - odoo.yaml - metabase.yaml + - backup.yaml - httproute.yaml From 96404c96e1bdbb4d192528bd728f0a6e3d9bc78a Mon Sep 17 00:00:00 2001 From: devops Date: Sun, 22 Nov 2026 02:43:17 -0500 Subject: [PATCH 77/88] apps(farrisilk): document backup schedule/restore/RPO + the filestore gap with measured evidence --- apps/base/farrisilk/README.md | 169 +++++++++++++++++++++++++++--- apps/base/farrisilk/postgres.yaml | 10 +- 2 files changed, 163 insertions(+), 16 deletions(-) diff --git a/apps/base/farrisilk/README.md b/apps/base/farrisilk/README.md index 99bdc1d..ae1fd3c 100644 --- a/apps/base/farrisilk/README.md +++ b/apps/base/farrisilk/README.md @@ -142,21 +142,166 @@ created over XML-RPC appears as a 697-byte file at exactly that path. are files. A database-only restore comes back looking healthy and every attachment, image and rendered artefact is gone. -## Backups — the gap, stated plainly +## Backups — the client's shape, implemented and measured -There are **no backups of this stack in the cluster**, and none are being added -by this card. +`backup.yaml` implements the **standard shape of the client's stated practice** +(a bash script on cron that dumps the database). It is *not* a copy of the +client's script — theirs has not been seen yet (Week 3 read-only audit item) — +and the label matters: everything below is what the *described* method does and +does not give you. -The client's practice is a **cron-driven `pg_dump` of the database only** — no -barman/PITR, no filestore copy. The replica mirrors that *shape*; the follow-up -card (`t_8bdd3708`) proves the failure mode deliberately rather than hiding it. -Two consequences to keep in mind while auditing: +### Schedule, retention, location -1. `pg_dump` of `odoo` + `metabase` reproduces Odoo's database and Metabase's - questions/dashboards. It does **not** reproduce `/var/lib/odoo/filestore`. -2. A DB-only restore therefore produces an Odoo instance where the attachment - list is intact and every download 404s. That is the client's real exposure - too, if their cron really copies only the DB. +| Item | Value | +|---|---| +| CronJob | `farrisilk/pg-backup` | +| Schedule | `17 3 * * *`, `timeZone: America/Los_Angeles` (nightly) | +| Guard rails | `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 600`, `backoffLimit: 1`, `activeDeadlineSeconds: 1800`, history 3 ok / 3 failed | +| Databases | `odoo` **and** `metabase`, one `pg_dump -Fc` each | +| Filename | `/backups/-.dump`, e.g. `odoo-20261122T074011Z.dump` | +| Retention | **14 days** (`RETENTION_DAYS=14`, `find /backups -name '*.dump' -mtime +14 -delete`) | +| Storage | PVC `backup-data`, 10 Gi, `local-path`, mounted at `/backups` | +| Script | ConfigMap `pg-backup-script` (`backup.sh`), no ServiceAccount/RBAC (default SA, token not mounted) | +| Credentials | `pg-app` Secret via env (`PGUSER`/`PGPASSWORD`) — never in git or in the manifest | + +Per-run log line (the only evidence a run happened; it lands in the Job pod log): + +``` +backup: ok db=odoo file=odoo-20261122T074011Z.dump size=2202025B toc_entries=4876 duration=1s +backup: ok db=metabase file=metabase-20261122T074011Z.dump size=1274779B toc_entries=2923 duration=0s +backup: retention sweep, deleting *.dump older than 14 days +backup: run complete rc=0 total=1s dumps_on_disk=2 +``` + +The script fails the Job (`rc=1`) if any `pg_dump` fails **or** if the archive +comes back with an empty TOC — a broken backup turns red instead of silently +succeeding, which a bare `pg_dump >> log 2>&1` cron does not do. + +**Where the dumps actually are:** `/opt/local-path-provisioner/pvc-8f164f6c-…_farrisilk_backup-data` +on **siriussec only**. `local-path` is node-local, so the backup dies with the +node. No off-box copy is implemented: the Garage S3 API at +`http://10.10.0.1:3900` is reachable from a pod, but it needs a bucket plus +credentials that are not part of this namespace, so it was not wired in one +pass. That absence is deliberate — it is the same absence in the client's +described setup. + +Trigger a run on demand (what the manual proof below did): + +```bash +kubectl -n farrisilk create job --from=cronjob/pg-backup pg-backup-manual-1 +kubectl -n farrisilk logs job/pg-backup-manual-1 +``` + +### Restore — it is TWO steps, and the second one is the one people forget + +**1. Database** (dumps live on the `backup-data` PVC; mount it in a throwaway pod +or exec where it is mounted): + +```bash +createdb -h pg -U postgres +pg_restore -h pg -U postgres -d /backups/odoo-.dump +psql -h pg -U postgres -d -tAc 'select count(*) from res_users' +``` + +Restoring into the same cluster works without extra flags because the `odoo` +role and the schema already exist; into a *different* cluster use +`--no-owner --no-privileges` (then re-assign ownership). `-Fc` archives are +also readable with `pg_restore --list` and can be inspected without touching a +database. + +**2. Filestore** — this backup does **not** contain it. Copy the attachment +bytes from the Odoo PVC by hand: + +```bash +# from the Odoo pod (uid 100): tar the filestore directory, not the DB +kubectl -n farrisilk exec deploy/odoo -- \ + tar czf - -C /var/lib/odoo filestore | gzip -d | tar xzf - -C +``` + +The directory name is the **database name**: `/var/lib/odoo/filestore/odoo`. +Restoring the dump into `odoo_restore_probe` makes Odoo look in +`/var/lib/odoo/filestore/odoo_restore_probe`, which does not exist — renaming or +copying the filestore tree to match the restored DB name is a required manual +step. + +### Proof from the 2026-11-22 run (numbers, not assertions) + +| Check | Result | +|---|---| +| Job | `pg-backup-manual-1` — `Complete 1/1`, pod `Completed` | +| odoo dump | 2,202,025 B, `pg_restore --list` = **4876** entries | +| metabase dump | 1,274,779 B, `pg_restore --list` = **2923** entries | +| Restore probe | `createdb odoo_restore_probe` → `pg_restore -d` → **rc 0** | +| Row counts | live `res_users`=**5** vs restored=**5**; live `ir_attachment`=**22** vs restored=**22** | +| Cleanup | `odoo_restore_probe` dropped; probe pods deleted | +| Retention sweep | 30-day-old `*.dump` deleted by the exact `find`, fresh file kept | + +### The gap this method carries — demonstrated, not asserted + +After the restore above, the database is complete and healthy. The attachments +are not: + +- Restored DB references **22** `ir_attachment` rows, **21** of them with a + `store_fname` (file bytes). +- The backup volume holds exactly **2** files: the two `.dump` archives. + **0 of the 21 referenced files** exist anywhere under `/backups` (checked + every `store_fname` against the volume). +- `pg_restore --list` contains **0** filestore/blob entries — the dump carries + rows, not bytes. +- The live filestore is **23 files / 732 KiB** under + `/var/lib/odoo/filestore/odoo`; none of it is in the backup. +- End-to-end: the same attachment id fetched from the **live** instance and from + a throwaway Odoo bound to the **restored** database: + + ``` + live /web/content/15 -> 200 25613B (res.partner 2, image_1024) + restored DB /web/content/15 -> 500 265B + live /web/content/22 -> 200 447998B (web assets bundle) + restored DB /web/content/22 -> 500 265B + ``` + + and the restored instance's log names the missing file exactly: + + ``` + FileNotFoundError: [Errno 2] No such file or directory: + '/var/lib/odoo/filestore/odoo_restore_probe/a3/a305c7712711bdddb2561500d8fcab0ead92ebd6' + ``` + +**User-visible consequence:** after a DB-only restore the database looks +perfectly healthy — users, invoices and records are all there — but every +invoice PDF, pricelist, product image and attachment download **404s or 500s**. +The client would discover this at the moment they need the backup, not before. + +### RPO / consistency statement + +- Nightly dump, **no WAL archiving, no PITR**: worst-case **RPO is 24 hours** of + orders, invoices and attachments. Anything written after 03:17 is gone. +- The dump is a single `pg_dump` per database and is **not point-in-time + consistent with the filestore**: files written while the dump runs are either + present on disk and absent from the DB, or referenced by the DB after the + dump snapshot but missing from any earlier filestore tar — even a correct + DB+filestore restore has a skew window. +- There is no automated restore test, no checksum/encryption, and no alert on a + failed cron run beyond the Job's own status. A silent `pg_dump` failure on a + cron is invisible until the day it is needed. + +### What the client's stated method does not cover (Week 3 remediation register) + +| # | Not covered | Impact | +|---|---|---| +| 1 | Filestore / attachment bytes | 22 attachment rows, 0 bytes restorable; all downloads/PDFs/images break after restore | +| 2 | WAL archiving / PITR | up to 24 h data loss; no restore to a point before a bad import/delete | +| 3 | Off-box copy | dumps sit on the same host as the database; host/disk/ransomware loss takes both | +| 4 | Restore testing | untested dumps are hypotheses; no evidence they restore | +| 5 | Point-in-time consistency DB↔filestore | skewed restores even when both are copied | +| 6 | Failure alerting/verification | a failed cron dump is silent; Job status is the only signal here | +| 7 | Encryption at rest / access control on dumps | plain `.dump` files readable by anyone with the volume | +| 8 | Retention policy enforcement beyond 14 d | unbounded growth or, if scripts differ, no policy at all | + +Closing these (barman/PITR, object storage, filestore tar+checksum, scheduled +restore drills) is an **architectural recommendation for the client**, not a +change to this replica — no CNPG/barman is added here on purpose: the replica +exists to reproduce the client's exposure. ## PDF reports diff --git a/apps/base/farrisilk/postgres.yaml b/apps/base/farrisilk/postgres.yaml index 8bbcae4..e74d693 100644 --- a/apps/base/farrisilk/postgres.yaml +++ b/apps/base/farrisilk/postgres.yaml @@ -6,10 +6,12 @@ # "improve" this into a CNPG Cluster: the point is to develop and audit against # the client's actual architecture, not ours. # -# Known gap (stated plainly on purpose): there are NO backups of this database. -# The client's practice is a cron-driven `pg_dump` of the DB only; that mirrors -# into a separate follow-up card for this namespace, and no PITR/barman story -# is being invented here. +# Backups: none at the database level — no WAL archive, no replica, no PITR. +# The client's practice (a cron-driven `pg_dump` of the DB only) is mirrored by +# `backup.yaml` in this directory: nightly logical dumps, 14-day retention, on a +# node-local PVC, with the filestore deliberately NOT covered. See README. +# Do not "improve" this into a CNPG Cluster: the point is to develop and audit +# against the client's actual architecture, not ours. apiVersion: v1 kind: PersistentVolumeClaim metadata: From 530320bbfeca1695761c344c613a085021612d4a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sun, 22 Nov 2026 05:42:52 -0500 Subject: [PATCH 78/88] ops(siriussec): bound CPU bursts to the 15W power budget siriussec is a T480 on a 5V/3A (15W) USB-C supply and died 2026-11-22 04:20 after ~12h on battery. Host PL1 was 25W with turbo on, so any sustained burst outran the adapter. Cap the two workload-side bursts that can pin cores: - forgejo-runner-amd64 dind: no CPU limit before -> add cpu: 3 - metabase + farrisilk metabase: cpu limit 2 -> 1 each (two JVMs = 4 threads) Host-side cap (PL1 12W/PL2 15W, no_turbo=1) is applied by cpu-power-cap.service on the node itself, not by this repo. --- apps/base/farrisilk/metabase.yaml | 3 ++- apps/base/forgejo/runner-amd64.yaml | 5 +++++ apps/base/metabase/deployment.yaml | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/base/farrisilk/metabase.yaml b/apps/base/farrisilk/metabase.yaml index 4cc9330..b8653e2 100644 --- a/apps/base/farrisilk/metabase.yaml +++ b/apps/base/farrisilk/metabase.yaml @@ -87,7 +87,8 @@ spec: cpu: 250m memory: 1Gi limits: - cpu: "2" + # Capped with the main Metabase: see apps/base/metabase/deployment.yaml + cpu: "1" memory: 2Gi --- apiVersion: v1 diff --git a/apps/base/forgejo/runner-amd64.yaml b/apps/base/forgejo/runner-amd64.yaml index 7fa6dba..459971e 100644 --- a/apps/base/forgejo/runner-amd64.yaml +++ b/apps/base/forgejo/runner-amd64.yaml @@ -117,6 +117,11 @@ spec: cpu: 200m memory: 512Mi limits: + # Hard ceiling on CI burst draw: siriussec is a laptop on a 15 W + # USB-C supply, and dind previously had no CPU limit, so one + # Android/x86_64 build could pin all 8 threads (~25 W package) + # and drain the battery faster than the adapter refills it. + cpu: 3 memory: 4Gi - name: runner image: code.forgejo.org/forgejo/runner:5.0.1 diff --git a/apps/base/metabase/deployment.yaml b/apps/base/metabase/deployment.yaml index d7c6fd2..2536dc6 100644 --- a/apps/base/metabase/deployment.yaml +++ b/apps/base/metabase/deployment.yaml @@ -79,5 +79,9 @@ spec: cpu: 250m memory: 1Gi limits: - cpu: "2" + # 2 → 1: two Metabase JVMs on the gateway node could together + # burst to 4 threads on a 15 W adapter. 1 core each keeps the + # node inside its power budget; UI latency is unaffected at this + # query volume. + cpu: "1" memory: 2Gi From 79206e0487a7c6eecbd29c42973a724e2d6d5303 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sun, 22 Nov 2026 05:54:53 -0500 Subject: [PATCH 79/88] ops(farrisilk): park the client replica stack to cut siriussec draw siriussec is on a 15 W USB-C adapter and low-battery-shutdown fired 2026-11-22 04:20. The farrisilk replica (Odoo + Metabase JVM + Postgres) is the largest single stack on that node and is not client production. Scale its three Deployments to 0 and suspend the nightly pg_dump; PVCs and data stay put. Restore: set replicas back to 1 in odoo.yaml, metabase.yaml, postgres.yaml and unsuspend backup.yaml, then let Flux reconcile. --- apps/base/farrisilk/backup.yaml | 2 ++ apps/base/farrisilk/metabase.yaml | 3 ++- apps/base/farrisilk/odoo.yaml | 5 ++++- apps/base/farrisilk/postgres.yaml | 5 +++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/base/farrisilk/backup.yaml b/apps/base/farrisilk/backup.yaml index 2e2567c..2e5e13a 100644 --- a/apps/base/farrisilk/backup.yaml +++ b/apps/base/farrisilk/backup.yaml @@ -92,6 +92,8 @@ metadata: labels: app.kubernetes.io/part-of: farrisilk spec: + # Parked with the stack (see odoo.yaml): no dumps while Postgres is at 0. + suspend: true # 03:17 America/Los_Angeles — one run per night, off the hour so it does not # collide with Odoo's own cron threads or Metabase syncs at :00. schedule: "17 3 * * *" diff --git a/apps/base/farrisilk/metabase.yaml b/apps/base/farrisilk/metabase.yaml index b8653e2..1c215a4 100644 --- a/apps/base/farrisilk/metabase.yaml +++ b/apps/base/farrisilk/metabase.yaml @@ -16,7 +16,8 @@ metadata: name: metabase namespace: farrisilk spec: - replicas: 1 + # Parked 2026-11-22 (power budget) — see apps/base/farrisilk/odoo.yaml. + replicas: 0 selector: matchLabels: app: metabase diff --git a/apps/base/farrisilk/odoo.yaml b/apps/base/farrisilk/odoo.yaml index 4c93f0f..859b17d 100644 --- a/apps/base/farrisilk/odoo.yaml +++ b/apps/base/farrisilk/odoo.yaml @@ -43,7 +43,10 @@ metadata: name: odoo namespace: farrisilk spec: - replicas: 1 + # Parked 2026-11-22: siriussec's 15 W adapter cannot carry this replica + # stack (Odoo + two JVM/Postgres processes) alongside the public gateway + # workloads. Set back to 1 to bring the client replica up; PVCs are kept. + replicas: 0 strategy: type: Recreate selector: diff --git a/apps/base/farrisilk/postgres.yaml b/apps/base/farrisilk/postgres.yaml index e74d693..c2710a2 100644 --- a/apps/base/farrisilk/postgres.yaml +++ b/apps/base/farrisilk/postgres.yaml @@ -30,8 +30,9 @@ metadata: name: pg namespace: farrisilk spec: - replicas: 1 - # RWO volume: two pods must never hold the data directory at once. + # Parked 2026-11-22 (power budget) — see apps/base/farrisilk/odoo.yaml. + # Recreate: the data directory must be released before anything restarts. + replicas: 0 strategy: type: Recreate selector: From 01db28dec5ccdd1254924fb7624d1e4b527177c7 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 23 Nov 2026 22:50:52 -0500 Subject: [PATCH 80/88] apps(forgejo): serve a declarative robots.txt that keeps non-portfolio paths out of the index Self-registration was open until 2026-11-20 and Google indexed spam profiles under forgejo.siriusdevops.com (/leonabrewton8, /charlinebrando, .../-/packages). The accounts are deleted and 404 now, but Forgejo's built-in robots.txt only blocks /explore/*?* and /user/, so /explore/repos and /search stay crawlable. Forgejo serves GITEA_CUSTOM=/data/gitea/public/robots.txt at /robots.txt, so mount a ConfigMap there (the supported custom-public override) and disallow /explore/*, /user/*, /search*, /api/*, /*/-/packages while allowing /sirius/* for the portfolio repos. --- apps/base/forgejo/custom-public.yaml | 32 ++++++++++++++++++++++++++++ apps/base/forgejo/deployment.yaml | 8 +++++++ apps/base/forgejo/kustomization.yaml | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 apps/base/forgejo/custom-public.yaml diff --git a/apps/base/forgejo/custom-public.yaml b/apps/base/forgejo/custom-public.yaml new file mode 100644 index 0000000..ee4232a --- /dev/null +++ b/apps/base/forgejo/custom-public.yaml @@ -0,0 +1,32 @@ +# Custom "public" assets served at the site root by Forgejo. +# +# GITEA_CUSTOM in the image is /data/gitea, so Forgejo serves +# /data/gitea/public/* at the root path. Mounting this ConfigMap there makes +# /robots.txt declarative instead of a hand-written file on the PVC +# (docs: forgejo.org/docs/latest/admin/advanced/search-engines-indexation). +# +# Why: self-registration was open until 2026-11-20 and spam profiles +# (/leonabrewton8, /charlinebrando, .../-/packages) were indexed by Google. +# The accounts are gone, but Forgejo's built-in robots.txt only disallows +# /explore/*?* (query strings) and /user/, leaving /explore/repos and +# /search crawlable. This keeps the owner's portfolio repos (/sirius/*) +# indexable and everything else out. +apiVersion: v1 +kind: ConfigMap +metadata: + name: forgejo-custom-public + namespace: forgejo +data: + robots.txt: | + # forgejo.siriusdevops.com + User-agent: * + Disallow: /explore/* + Disallow: /user/* + Disallow: /search* + Disallow: /api/* + Disallow: /*/-/packages + Disallow: /repo/create + Disallow: /repo/migrate + Disallow: /org/create + + Allow: /sirius/* diff --git a/apps/base/forgejo/deployment.yaml b/apps/base/forgejo/deployment.yaml index 4a430ea..1a6c467 100644 --- a/apps/base/forgejo/deployment.yaml +++ b/apps/base/forgejo/deployment.yaml @@ -61,6 +61,11 @@ spec: volumeMounts: - name: data mountPath: /data + # Custom site-root assets (robots.txt). GITEA_CUSTOM=/data/gitea, + # so Forgejo serves /data/gitea/public/robots.txt at /robots.txt. + - name: custom-public + mountPath: /data/gitea/public + readOnly: true readinessProbe: httpGet: path: / @@ -77,3 +82,6 @@ spec: - name: data persistentVolumeClaim: claimName: forgejo-data + - name: custom-public + configMap: + name: forgejo-custom-public diff --git a/apps/base/forgejo/kustomization.yaml b/apps/base/forgejo/kustomization.yaml index 709c518..4c69535 100644 --- a/apps/base/forgejo/kustomization.yaml +++ b/apps/base/forgejo/kustomization.yaml @@ -7,6 +7,8 @@ resources: - cluster.yaml - podmonitor.yaml - pg-actions-queries.yaml + # Site-root custom assets (robots.txt) mounted into the forgejo pod. + - custom-public.yaml - deployment.yaml - service.yaml - runner-configmap.yaml From 82f0d8324368d0c3bef82e36f18f67339086c0fc Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 23 Nov 2026 22:54:10 -0500 Subject: [PATCH 81/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=20e?= =?UTF-8?q?2fd76a=20=E2=80=94=20/book=20drops=20the=20public=20audit=20pri?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit siriusdevops-site:e2fd76ad (merge of PR #19) replaces the $750–$1,500 audit anchor in the /book funnel with 'scoped and quoted after the review'. contact-api is unchanged at 8642f1a. --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 5be80b1..7732245 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:799afe40192182cd418652a638376f06e3b1adeb + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:e2fd76ad1dfeb6c758974f04a9b3d3308c78d43d imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 648516af71ac54fba857c900e116d11f9fc63f40 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 23 Nov 2026 23:09:23 -0500 Subject: [PATCH 82/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=20a?= =?UTF-8?q?f139906=20=E2=80=94=20five-band=20homepage=20repositioning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 7732245..4ccecfd 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:e2fd76ad1dfeb6c758974f04a9b3d3308c78d43d + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:af139906411167a382f072184cce526a82729083 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From cc50d1c231cdf860c1471e59fa65adbe2db0735d Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 23 Nov 2026 23:28:27 -0500 Subject: [PATCH 83/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=20f?= =?UTF-8?q?e2d5bb=20=E2=80=94=20Quiet=20Precision=20token=20pass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 4ccecfd..fdac4e4 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:af139906411167a382f072184cce526a82729083 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:fe2d5bbda956f66f8de6918a48d5c3e2952053ff imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 5b26ecd8235e0b9d42a8418d1a0a4c69f52db97e Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Mon, 23 Nov 2026 23:43:30 -0500 Subject: [PATCH 84/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=200?= =?UTF-8?q?e91b466=20=E2=80=94=20/lab=20briefs=20rewrite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index fdac4e4..fa0a0e0 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:fe2d5bbda956f66f8de6918a48d5c3e2952053ff + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:0e91b466e2e07edf73f456dcab240fcf397ad5ce imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 955f886d3616e54b8e5e8238f4e878a96aabcebc Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 24 Nov 2026 00:02:35 -0500 Subject: [PATCH 85/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=203?= =?UTF-8?q?98b5353=20=E2=80=94=20homepage=20sheet=20roles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index fa0a0e0..8c94499 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:0e91b466e2e07edf73f456dcab240fcf397ad5ce + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:398b5353f2cb24547f946d6bd306d7f3634ec671 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From f5cb4ec22aaded4dd467e7350ee6593d173a9e62 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 24 Nov 2026 00:09:28 -0500 Subject: [PATCH 86/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=200?= =?UTF-8?q?4b36fed=20=E2=80=94=20telemetry=207=20/=207=20Flux=20Kustomizat?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 8c94499..7d5077d 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:398b5353f2cb24547f946d6bd306d7f3634ec671 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:04b36fedf47e53f9d2b8bb59958faf90ebb3d9b8 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From f9888c63f06d2879addee2f36a60b069f234ddd0 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 24 Nov 2026 00:20:02 -0500 Subject: [PATCH 87/88] =?UTF-8?q?apps(siriusdevops):=20pin=20site=20to=203?= =?UTF-8?q?99c421f=20=E2=80=94=20zero=20em=20dashes=20on=20/,=20/book,=20/?= =?UTF-8?q?lab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index 7d5077d..67f1fe5 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -75,7 +75,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:04b36fedf47e53f9d2b8bb59958faf90ebb3d9b8 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:399c421f51a2fd74a87e810641226d58e4e22690 imagePullPolicy: IfNotPresent ports: - containerPort: 80 From ae22aab3303531a40a5aa030420727e8d7f263da Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 24 Nov 2026 01:46:25 -0500 Subject: [PATCH 88/88] =?UTF-8?q?apps(customer1):=20anonymize=20client=20n?= =?UTF-8?q?ame=20=E2=80=94=20farrisilk=20->=20customer1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the client-shaped lab replica namespace and its manifests to keep the client name out of the repo going forward (git history is intentionally not rewritten). - apps/base/farrisilk -> apps/base/customer1 (namespace, workloads, PVCs, HTTPRoutes, backup CronJob, README) - infrastructure/networking/internal/gateway-farrisilk-{odoo,metabase}.yaml -> gateway-customer1-{odoo,metabase}.yaml (listener ports unchanged: 8086/8087) - firewall comment headers updated (rules/ports untouched) No functional change beyond object names; workloads remain parked at 0. --- apps/base/{farrisilk => customer1}/README.md | 40 +++++++++---------- .../base/{farrisilk => customer1}/backup.yaml | 16 ++++---- .../{farrisilk => customer1}/httproute.yaml | 12 +++--- .../kustomization.yaml | 14 +++---- .../{farrisilk => customer1}/metabase.yaml | 14 +++---- .../{farrisilk => customer1}/namespace.yaml | 4 +- .../{farrisilk => customer1}/odoo-init.yaml | 8 ++-- apps/base/{farrisilk => customer1}/odoo.yaml | 14 +++---- .../postgres-init.yaml | 4 +- .../{farrisilk => customer1}/postgres.yaml | 10 ++--- apps/home/kustomization.yaml | 2 +- ...e.yaml => gateway-customer1-metabase.yaml} | 8 ++-- ...-odoo.yaml => gateway-customer1-odoo.yaml} | 4 +- .../host-firewall/rpi-ufw-internal-gw.sh | 4 +- .../host-firewall/siriussec-internal-gw.nft | 2 +- .../networking/internal/kustomization.yaml | 4 +- 16 files changed, 80 insertions(+), 80 deletions(-) rename apps/base/{farrisilk => customer1}/README.md (94%) rename apps/base/{farrisilk => customer1}/backup.yaml (95%) rename apps/base/{farrisilk => customer1}/httproute.yaml (81%) rename apps/base/{farrisilk => customer1}/kustomization.yaml (50%) rename apps/base/{farrisilk => customer1}/metabase.yaml (89%) rename apps/base/{farrisilk => customer1}/namespace.yaml (63%) rename apps/base/{farrisilk => customer1}/odoo-init.yaml (96%) rename apps/base/{farrisilk => customer1}/odoo.yaml (96%) rename apps/base/{farrisilk => customer1}/postgres-init.yaml (97%) rename apps/base/{farrisilk => customer1}/postgres.yaml (95%) rename infrastructure/networking/internal/{gateway-farrisilk-metabase.yaml => gateway-customer1-metabase.yaml} (72%) rename infrastructure/networking/internal/{gateway-farrisilk-odoo.yaml => gateway-customer1-odoo.yaml} (91%) diff --git a/apps/base/farrisilk/README.md b/apps/base/customer1/README.md similarity index 94% rename from apps/base/farrisilk/README.md rename to apps/base/customer1/README.md index ae1fd3c..9d13b97 100644 --- a/apps/base/farrisilk/README.md +++ b/apps/base/customer1/README.md @@ -1,14 +1,14 @@ -# farrisilk — lab replica of the Farrisilk client stack +# customer1 — lab replica of the Customer 1 client stack -A **development/audit sandbox** shaped like Farrisilk Inc.'s production stack — +A **development/audit sandbox** shaped like Customer 1 Inc.'s production stack — not a copy of their traffic, and not their architecture. Odoo 18 + a plain -PostgreSQL + Metabase, WireGuard-only, in namespace `farrisilk`. +PostgreSQL + Metabase, WireGuard-only, in namespace `customer1`. | Service | URL over WireGuard | Bare IP? | Notes | |---|---|---|---| | Odoo 18 | `http://10.10.0.2:8086/` | yes, any `Host` | `http://10.10.0.2:8086/web/login` | | Metabase | `http://10.10.0.2:8087/` | yes, any `Host` | secondary instance, 1 GiB heap | -| PostgreSQL | `pg.farrisilk.svc.cluster.local:5432` | in-cluster only | no NodePort, no gateway | +| PostgreSQL | `pg.customer1.svc.cluster.local:5432` | in-cluster only | no NodePort, no gateway | `10.10.0.2` is siriussec, the only node labelled `gateway=true` (the only node running `cilium-envoy`). Nothing here has a public hostname, a tunnel entry or a @@ -41,8 +41,8 @@ This namespace is our sandbox for developing and auditing against *their* shape: | Two hostname-less HTTPRoutes | `httproute.yaml` | Gateways live with the other internal listeners: -`infrastructure/networking/internal/gateway-farrisilk-odoo.yaml` (8086) and -`gateway-farrisilk-metabase.yaml` (8087). **Each bare-IP service gets its own +`infrastructure/networking/internal/gateway-customer1-odoo.yaml` (8086) and +`gateway-customer1-metabase.yaml` (8087). **Each bare-IP service gets its own Gateway**: Cilium renders one RouteConfiguration per Gateway and merges every hostname-less route inside it into a weighted route, so two services sharing a Gateway answer for each other at random. The host firewall @@ -65,7 +65,7 @@ separate Job to race against: - `CREATE EXTENSION IF NOT EXISTS unaccent` as the database owner; - (re)applies the read-only BI grants and credential-table revokes, every start, so tables added by a later module install are covered too; - - sets the admin login/password from Secret `farrisilk/odoo-admin` via + - sets the admin login/password from Secret `customer1/odoo-admin` via `odoo shell`. Restarting the pod is safe and visibly idempotent: @@ -80,9 +80,9 @@ Copy the module directory into the `odoo-extra-addons` PVC, then install it through the ORM: ```bash -POD=$(kubectl -n farrisilk get pod -l app=odoo -o name | head -1) -kubectl -n farrisilk cp ./client_module "${POD#pod/}:/mnt/extra-addons/client_module" -c odoo -kubectl -n farrisilk exec -i deploy/odoo -c odoo -- \ +POD=$(kubectl -n customer1 get pod -l app=odoo -o name | head -1) +kubectl -n customer1 cp ./client_module "${POD#pod/}:/mnt/extra-addons/client_module" -c odoo +kubectl -n customer1 exec -i deploy/odoo -c odoo -- \ odoo shell -c /etc/odoo-runtime/odoo.conf -d odoo --no-http --shell-interface=python <<'EOF' m = env['ir.module.module'].search([('name', '=', 'client_module')]) m.button_immediate_install() @@ -91,7 +91,7 @@ print(m.state) EOF ``` -Then `kubectl -n farrisilk delete pod -l app=odoo` once, so `init-db` re-applies +Then `kubectl -n customer1 delete pod -l app=odoo` once, so `init-db` re-applies the `metabase_ro` SELECT grants to the tables the module just created (grants are re-applied on every pod start; `ALTER DEFAULT PRIVILEGES` covers tables created after the grant but not before it). @@ -154,7 +154,7 @@ does not give you. | Item | Value | |---|---| -| CronJob | `farrisilk/pg-backup` | +| CronJob | `customer1/pg-backup` | | Schedule | `17 3 * * *`, `timeZone: America/Los_Angeles` (nightly) | | Guard rails | `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 600`, `backoffLimit: 1`, `activeDeadlineSeconds: 1800`, history 3 ok / 3 failed | | Databases | `odoo` **and** `metabase`, one `pg_dump -Fc` each | @@ -177,7 +177,7 @@ The script fails the Job (`rc=1`) if any `pg_dump` fails **or** if the archive comes back with an empty TOC — a broken backup turns red instead of silently succeeding, which a bare `pg_dump >> log 2>&1` cron does not do. -**Where the dumps actually are:** `/opt/local-path-provisioner/pvc-8f164f6c-…_farrisilk_backup-data` +**Where the dumps actually are:** `/opt/local-path-provisioner/pvc-8f164f6c-…_customer1_backup-data` on **siriussec only**. `local-path` is node-local, so the backup dies with the node. No off-box copy is implemented: the Garage S3 API at `http://10.10.0.1:3900` is reachable from a pod, but it needs a bucket plus @@ -188,8 +188,8 @@ described setup. Trigger a run on demand (what the manual proof below did): ```bash -kubectl -n farrisilk create job --from=cronjob/pg-backup pg-backup-manual-1 -kubectl -n farrisilk logs job/pg-backup-manual-1 +kubectl -n customer1 create job --from=cronjob/pg-backup pg-backup-manual-1 +kubectl -n customer1 logs job/pg-backup-manual-1 ``` ### Restore — it is TWO steps, and the second one is the one people forget @@ -214,7 +214,7 @@ bytes from the Odoo PVC by hand: ```bash # from the Odoo pod (uid 100): tar the filestore directory, not the DB -kubectl -n farrisilk exec deploy/odoo -- \ +kubectl -n customer1 exec deploy/odoo -- \ tar czf - -C /var/lib/odoo filestore | gzip -d | tar xzf - -C ``` @@ -322,13 +322,13 @@ If a future image drops wkhtmltopdf, the fix is a derived image 2 GiB — this is a *second* Metabase next to the `metabase` namespace evaluation instance and does not repeat its 1.5 GiB heap on this laptop. - State lives in the same Postgres, database `metabase`, user `metabase`. -- **`MB_ENCRYPTION_SECRET_KEY` is set** (Secret `farrisilk/metabase-secret-key`) +- **`MB_ENCRYPTION_SECRET_KEY` is set** (Secret `customer1/metabase-secret-key`) so stored data-source passwords are not encrypted with Metabase's default key. Keep it stable: rotating it makes every stored datasource password undecryptable. - Set up entirely through the API (`/api/session/properties` → `POST /api/setup` → `POST /api/session` → `POST /api/database` → `sync_schema`), one data source: - **`farrisilk odoo`** → `pg.farrisilk.svc.cluster.local:5432/odoo` as + **`customer1 odoo`** → `pg.customer1.svc.cluster.local:5432/odoo` as `metabase_ro`. - Metabase has no per-database "read-only" switch for PostgreSQL sources; the read-only guarantee here is the **role**, which is stronger (see below). @@ -386,7 +386,7 @@ Created before the Kustomization applies; never in git, never printed: | `odoo-config` | `admin_passwd` | Odoo database master password | | `odoo-admin` | `email`, `password` | Odoo web admin login (uid 2) | | `metabase-admin` | `email`, `password` | Metabase's own login (**email**, no username) | -| `metabase-data-source-creds` | `username`=metabase_ro, `password` | the `farrisilk odoo` data source | +| `metabase-data-source-creds` | `username`=metabase_ro, `password` | the `customer1 odoo` data source | | `metabase-secret-key` | `MB_ENCRYPTION_SECRET_KEY` | Metabase at-rest encryption | ## Shopify — integration surface only, blocked on client credentials @@ -415,7 +415,7 @@ the connector module). Until then the Odoo side stays unconfigured on purpose. - The card's build section names db `odoo` (owner `odoo`), §4 grants on database `odoo`, and Metabase's data source is `…:5432/odoo`, while the Odoo - config bullet said `db_name=farrisilk`. Those cannot both hold; the stack is + config bullet said `db_name=customer1`. Those cannot both hold; the stack is aligned on **`odoo`** (`db_name`, `dbfilter=^odoo$`, `ODOO_DB_NAME`, the BI grants and the Metabase source all say `odoo`). - `base,web` are installed (not `base` alone) so `/web/login` serves a real web diff --git a/apps/base/farrisilk/backup.yaml b/apps/base/customer1/backup.yaml similarity index 95% rename from apps/base/farrisilk/backup.yaml rename to apps/base/customer1/backup.yaml index 2e5e13a..4ed7a84 100644 --- a/apps/base/farrisilk/backup.yaml +++ b/apps/base/customer1/backup.yaml @@ -22,9 +22,9 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: backup-data - namespace: farrisilk + namespace: customer1 labels: - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 spec: accessModes: [ReadWriteOnce] storageClassName: local-path @@ -36,9 +36,9 @@ apiVersion: v1 kind: ConfigMap metadata: name: pg-backup-script - namespace: farrisilk + namespace: customer1 labels: - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 data: backup.sh: | #!/bin/sh @@ -88,9 +88,9 @@ apiVersion: batch/v1 kind: CronJob metadata: name: pg-backup - namespace: farrisilk + namespace: customer1 labels: - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 spec: # Parked with the stack (see odoo.yaml): no dumps while Postgres is at 0. suspend: true @@ -110,7 +110,7 @@ spec: metadata: labels: app: pg-backup - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 spec: restartPolicy: Never automountServiceAccountToken: false @@ -132,7 +132,7 @@ spec: command: ["/bin/sh", "/opt/backup/backup.sh"] env: - name: PGHOST - value: pg.farrisilk.svc.cluster.local + value: pg.customer1.svc.cluster.local - name: PGPORT value: "5432" - name: PGUSER diff --git a/apps/base/farrisilk/httproute.yaml b/apps/base/customer1/httproute.yaml similarity index 81% rename from apps/base/farrisilk/httproute.yaml rename to apps/base/customer1/httproute.yaml index 5c99157..b870d0e 100644 --- a/apps/base/farrisilk/httproute.yaml +++ b/apps/base/customer1/httproute.yaml @@ -5,16 +5,16 @@ # cannot edit /etc/hosts. Cilium renders ONE RouteConfiguration per Gateway and # merges every hostname-less route in it into a single weighted route, so two # services sharing one Gateway serve each other's traffic at random regardless -# of listener port. Hence gateway-farrisilk-odoo.yaml (8086) and -# gateway-farrisilk-metabase.yaml (8087) in infrastructure/networking/internal/. +# of listener port. Hence gateway-customer1-odoo.yaml (8086) and +# gateway-customer1-metabase.yaml (8087) in infrastructure/networking/internal/. apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: odoo - namespace: farrisilk + namespace: customer1 spec: parentRefs: - - name: farrisilk-odoo + - name: customer1-odoo namespace: internal rules: - matches: @@ -29,10 +29,10 @@ apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: metabase - namespace: farrisilk + namespace: customer1 spec: parentRefs: - - name: farrisilk-metabase + - name: customer1-metabase namespace: internal rules: - matches: diff --git a/apps/base/farrisilk/kustomization.yaml b/apps/base/customer1/kustomization.yaml similarity index 50% rename from apps/base/farrisilk/kustomization.yaml rename to apps/base/customer1/kustomization.yaml index ed462db..b25ead7 100644 --- a/apps/base/farrisilk/kustomization.yaml +++ b/apps/base/customer1/kustomization.yaml @@ -3,13 +3,13 @@ kind: Kustomization resources: - namespace.yaml # Secrets are created out of band, before this Kustomization applies: - # farrisilk/pg-app basic-auth, postgres superuser - # farrisilk/pg-users odoo/metabase/metabase_ro role passwords - # farrisilk/odoo-config admin_passwd (database master password) - # farrisilk/odoo-admin email, password (web admin login) - # farrisilk/metabase-admin email, password (Metabase's own login) - # farrisilk/metabase-data-source-creds username=metabase_ro + password - # farrisilk/metabase-secret-key MB_ENCRYPTION_SECRET_KEY + # customer1/pg-app basic-auth, postgres superuser + # customer1/pg-users odoo/metabase/metabase_ro role passwords + # customer1/odoo-config admin_passwd (database master password) + # customer1/odoo-admin email, password (web admin login) + # customer1/metabase-admin email, password (Metabase's own login) + # customer1/metabase-data-source-creds username=metabase_ro + password + # customer1/metabase-secret-key MB_ENCRYPTION_SECRET_KEY # None of them appear in git; they are not managed (or pruned) by Flux. - postgres-init.yaml - postgres.yaml diff --git a/apps/base/farrisilk/metabase.yaml b/apps/base/customer1/metabase.yaml similarity index 89% rename from apps/base/farrisilk/metabase.yaml rename to apps/base/customer1/metabase.yaml index 1c215a4..0fac78f 100644 --- a/apps/base/farrisilk/metabase.yaml +++ b/apps/base/customer1/metabase.yaml @@ -1,5 +1,5 @@ # Metabase for the lab replica — its own state in the SAME plain Postgres -# (database `metabase`), one data source: `farrisilk odoo` as `metabase_ro`. +# (database `metabase`), one data source: `customer1 odoo` as `metabase_ro`. # # This is a SECOND instance next to the evaluation one in namespace `metabase`. # The laptop is on a marginal USB-C supply, so it does not repeat that @@ -8,15 +8,15 @@ # MB_ENCRYPTION_SECRET_KEY is set here on purpose. Without it Metabase encrypts # stored data-source passwords with a key derived from its own default, so a # copy of the app DB is enough to read them. The key lives in Secret -# `farrisilk/metabase-secret-key` and must stay stable for the life of the app +# `customer1/metabase-secret-key` and must stay stable for the life of the app # DB — rotating it makes every stored datasource password undecryptable. apiVersion: apps/v1 kind: Deployment metadata: name: metabase - namespace: farrisilk + namespace: customer1 spec: - # Parked 2026-11-22 (power budget) — see apps/base/farrisilk/odoo.yaml. + # Parked 2026-11-22 (power budget) — see apps/base/customer1/odoo.yaml. replicas: 0 selector: matchLabels: @@ -25,7 +25,7 @@ spec: metadata: labels: app: metabase - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 spec: nodeSelector: kubernetes.io/hostname: siriussec @@ -46,7 +46,7 @@ spec: - name: MB_DB_TYPE value: postgres - name: MB_DB_HOST - value: pg.farrisilk.svc.cluster.local + value: pg.customer1.svc.cluster.local - name: MB_DB_PORT value: "5432" - name: MB_DB_DBNAME @@ -96,7 +96,7 @@ apiVersion: v1 kind: Service metadata: name: metabase - namespace: farrisilk + namespace: customer1 spec: type: ClusterIP selector: diff --git a/apps/base/farrisilk/namespace.yaml b/apps/base/customer1/namespace.yaml similarity index 63% rename from apps/base/farrisilk/namespace.yaml rename to apps/base/customer1/namespace.yaml index d06ff54..0fed73f 100644 --- a/apps/base/farrisilk/namespace.yaml +++ b/apps/base/customer1/namespace.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Namespace metadata: - name: farrisilk + name: customer1 labels: - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 sirius.dev/purpose: lab-replica-of-client-stack diff --git a/apps/base/farrisilk/odoo-init.yaml b/apps/base/customer1/odoo-init.yaml similarity index 96% rename from apps/base/farrisilk/odoo-init.yaml rename to apps/base/customer1/odoo-init.yaml index 47cf718..cd90251 100644 --- a/apps/base/farrisilk/odoo-init.yaml +++ b/apps/base/customer1/odoo-init.yaml @@ -9,7 +9,7 @@ # 3. CREATE EXTENSION unaccent, as the database owner # 4. (re)apply the read-only BI grants over every table Odoo just created, # including revoking the tables that carry credentials -# 5. set the admin login/password from Secret `farrisilk/odoo-admin` +# 5. set the admin login/password from Secret `customer1/odoo-admin` # # Step 4 runs unconditionally, not only on first install: it is what picks up # tables added by a later module install (`-i`/`-u` from /mnt/extra-addons), and @@ -19,11 +19,11 @@ apiVersion: v1 kind: ConfigMap metadata: name: odoo-init - namespace: farrisilk + namespace: customer1 data: init_db.py: | #!/usr/bin/env python3 - """Idempotent first-run provisioning of the Farrisilk lab Odoo database.""" + """Idempotent first-run provisioning of the Customer 1 lab Odoo database.""" import os import subprocess import sys @@ -157,7 +157,7 @@ data: print(f"metabase_ro: SELECT granted on {readable} tables; " f"revoked on {revoked}", flush=True) - # Admin login/password from Secret farrisilk/odoo-admin. `odoo shell` is + # Admin login/password from Secret customer1/odoo-admin. `odoo shell` is # the supported way to set a res.users password without hand-rolling a # pbkdf2 hash. Re-writing the same value on every start is harmless. payload = ( diff --git a/apps/base/farrisilk/odoo.yaml b/apps/base/customer1/odoo.yaml similarity index 96% rename from apps/base/farrisilk/odoo.yaml rename to apps/base/customer1/odoo.yaml index 859b17d..3ba36d4 100644 --- a/apps/base/farrisilk/odoo.yaml +++ b/apps/base/customer1/odoo.yaml @@ -1,4 +1,4 @@ -# Odoo 18 — the application half of the Farrisilk lab replica. +# Odoo 18 — the application half of the Customer 1 lab replica. # # Image is pinned to the DATED build, never `18.0`/`latest`: Odoo auto-migrates # its database schema on start, so a floating tag turns a pod restart into an @@ -12,7 +12,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: odoo-data - namespace: farrisilk + namespace: customer1 spec: accessModes: [ReadWriteOnce] storageClassName: local-path @@ -21,7 +21,7 @@ spec: storage: 10Gi --- # Empty by default. This is where the client's custom modules are copied in -# (`kubectl cp ./module farrisilk/:/mnt/extra-addons/...`), which is +# (`kubectl cp ./module customer1/:/mnt/extra-addons/...`), which is # why it is a PVC and not an emptyDir: a module installed from here must survive # a pod restart, or the modules table and the addons path disagree and Odoo # refuses to start the affected modules. @@ -29,7 +29,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: odoo-extra-addons - namespace: farrisilk + namespace: customer1 spec: accessModes: [ReadWriteOnce] storageClassName: local-path @@ -41,7 +41,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: odoo - namespace: farrisilk + namespace: customer1 spec: # Parked 2026-11-22: siriussec's 15 W adapter cannot carry this replica # stack (Odoo + two JVM/Postgres processes) alongside the public gateway @@ -56,7 +56,7 @@ spec: metadata: labels: app: odoo - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 spec: # Envoy has to reach the backend on the same node it serves from, and the # filestore PVC is local-path (siriussec-only anyway). @@ -249,7 +249,7 @@ apiVersion: v1 kind: Service metadata: name: odoo - namespace: farrisilk + namespace: customer1 spec: type: ClusterIP selector: diff --git a/apps/base/farrisilk/postgres-init.yaml b/apps/base/customer1/postgres-init.yaml similarity index 97% rename from apps/base/farrisilk/postgres-init.yaml rename to apps/base/customer1/postgres-init.yaml index 652de5e..06b3998 100644 --- a/apps/base/farrisilk/postgres-init.yaml +++ b/apps/base/customer1/postgres-init.yaml @@ -13,13 +13,13 @@ # installed them (the odoo Deployment's initContainer), because # at this point the `odoo` database has no tables at all. # -# Passwords arrive as env vars from Secret `farrisilk/pg-users` (out of band); +# Passwords arrive as env vars from Secret `customer1/pg-users` (out of band); # nothing here is a credential literal. apiVersion: v1 kind: ConfigMap metadata: name: pg-init - namespace: farrisilk + namespace: customer1 data: 01-init-dbs.sh: | #!/bin/bash diff --git a/apps/base/farrisilk/postgres.yaml b/apps/base/customer1/postgres.yaml similarity index 95% rename from apps/base/farrisilk/postgres.yaml rename to apps/base/customer1/postgres.yaml index c2710a2..2de1599 100644 --- a/apps/base/farrisilk/postgres.yaml +++ b/apps/base/customer1/postgres.yaml @@ -16,7 +16,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pg-data - namespace: farrisilk + namespace: customer1 spec: accessModes: [ReadWriteOnce] storageClassName: local-path @@ -28,9 +28,9 @@ apiVersion: apps/v1 kind: Deployment metadata: name: pg - namespace: farrisilk + namespace: customer1 spec: - # Parked 2026-11-22 (power budget) — see apps/base/farrisilk/odoo.yaml. + # Parked 2026-11-22 (power budget) — see apps/base/customer1/odoo.yaml. # Recreate: the data directory must be released before anything restarts. replicas: 0 strategy: @@ -42,7 +42,7 @@ spec: metadata: labels: app: pg - app.kubernetes.io/part-of: farrisilk + app.kubernetes.io/part-of: customer1 spec: nodeSelector: kubernetes.io/hostname: siriussec @@ -131,7 +131,7 @@ apiVersion: v1 kind: Service metadata: name: pg - namespace: farrisilk + namespace: customer1 spec: type: ClusterIP selector: diff --git a/apps/home/kustomization.yaml b/apps/home/kustomization.yaml index 55b2076..de35548 100644 --- a/apps/home/kustomization.yaml +++ b/apps/home/kustomization.yaml @@ -7,4 +7,4 @@ resources: - ../base/sirius-growth - ../base/osint - ../base/metabase - - ../base/farrisilk + - ../base/customer1 diff --git a/infrastructure/networking/internal/gateway-farrisilk-metabase.yaml b/infrastructure/networking/internal/gateway-customer1-metabase.yaml similarity index 72% rename from infrastructure/networking/internal/gateway-farrisilk-metabase.yaml rename to infrastructure/networking/internal/gateway-customer1-metabase.yaml index 8619fb6..9c8ece1 100644 --- a/infrastructure/networking/internal/gateway-farrisilk-metabase.yaml +++ b/infrastructure/networking/internal/gateway-customer1-metabase.yaml @@ -1,5 +1,5 @@ -# Own Gateway for the Farrisilk lab Metabase (:8087) — see -# gateway-farrisilk-odoo.yaml for why one bare-IP service per Gateway. +# Own Gateway for the Customer 1 lab Metabase (:8087) — see +# gateway-customer1-odoo.yaml for why one bare-IP service per Gateway. # # This is NOT the evaluation instance in namespace `metabase` (:8085). Same # reasoning applies to the port choice: one listener port carries exactly one @@ -7,12 +7,12 @@ apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: - name: farrisilk-metabase + name: customer1-metabase namespace: internal labels: dedicated: network annotations: - sirius.dev/purpose: bare-IP listener for the Farrisilk lab Metabase (WireGuard only) + sirius.dev/purpose: bare-IP listener for the Customer 1 lab Metabase (WireGuard only) spec: gatewayClassName: cilium listeners: diff --git a/infrastructure/networking/internal/gateway-farrisilk-odoo.yaml b/infrastructure/networking/internal/gateway-customer1-odoo.yaml similarity index 91% rename from infrastructure/networking/internal/gateway-farrisilk-odoo.yaml rename to infrastructure/networking/internal/gateway-customer1-odoo.yaml index 5a65a7b..d0d5315 100644 --- a/infrastructure/networking/internal/gateway-farrisilk-odoo.yaml +++ b/infrastructure/networking/internal/gateway-customer1-odoo.yaml @@ -12,12 +12,12 @@ apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: - name: farrisilk-odoo + name: customer1-odoo namespace: internal labels: dedicated: network annotations: - sirius.dev/purpose: bare-IP listener for the Farrisilk lab Odoo (WireGuard only) + sirius.dev/purpose: bare-IP listener for the Customer 1 lab Odoo (WireGuard only) spec: gatewayClassName: cilium listeners: diff --git a/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh b/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh index 16dfe94..f20e0f8 100644 --- a/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh +++ b/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh @@ -8,8 +8,8 @@ # Ports: 8081 = Grafana (`internal` Gateway listener http-internal), # 8084 = Hubble UI (`internal` Gateway listener hubble-ui), # 8085 = Metabase (`metabase` Gateway listener http-internal), -# 8086 = Farrisilk lab Odoo (`farrisilk-odoo` Gateway), -# 8087 = Farrisilk lab Metabase (`farrisilk-metabase` Gateway). +# 8086 = Customer 1 lab Odoo (`customer1-odoo` Gateway), +# 8087 = Customer 1 lab Metabase (`customer1-metabase` Gateway). # Add a new internal listener port to PORTS; the loop is idempotent, so # re-running after a port is already firewalled only adds what is missing. # diff --git a/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft b/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft index 046a53c..6f07915 100644 --- a/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft +++ b/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft @@ -1,6 +1,6 @@ #!/usr/sbin/nft -f # Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana), 8084 -# (Hubble UI), 8085 (Metabase) and 8086/8087 (Farrisilk lab replica: Odoo, +# (Hubble UI), 8085 (Metabase) and 8086/8087 (Customer 1 lab replica: Odoo, # Metabase). # # Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the diff --git a/infrastructure/networking/internal/kustomization.yaml b/infrastructure/networking/internal/kustomization.yaml index fc93e64..a0c4937 100644 --- a/infrastructure/networking/internal/kustomization.yaml +++ b/infrastructure/networking/internal/kustomization.yaml @@ -5,5 +5,5 @@ resources: - gateway.yaml - gateway-hubble-ui.yaml - gateway-metabase.yaml - - gateway-farrisilk-odoo.yaml - - gateway-farrisilk-metabase.yaml + - gateway-customer1-odoo.yaml + - gateway-customer1-metabase.yaml