From a4cc2d87bcea0ef38acaec3dbf672491646fb3ed Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Fri, 27 Nov 2026 00:30:22 -0500 Subject: [PATCH] secrets: SOPS the backup SSH key and monitoring's hand-made Secrets (F12, part 2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completes F12 on the objects deliberately held back until the delete-and-reconcile drill on siriusdevops/siriusdevops-contact had proved the path works (it did: deleted 05:29:03Z, recreated by Flux 05:29:05Z, byte-identical, pod restarted off the recovered Secret and /health 200 — see docs/secrets-sops.md). * cluster-backup-ssh in forgejo, sirius-growth and monitoring — three files, one plaintext ed25519 key: a Secret cannot cross namespaces and each backup CronJob mounts its own namespace's copy, so all three must exist and all three must be rotated together. * monitoring/grafana-admin, monitoring/grafana-secret-key and monitoring/alertmanager-telegram, which are the *inputs* the prometheus-operator and Grafana consume; the operator's rendered prometheus-*/alertmanager-* objects stay excluded (a second writer would fight it). * monitoring Kustomization gains the same sops decryption block as apps. All six files were generated from the live objects and decrypt to a byte-identical data map and type, so this apply is a no-op. --- apps/base/forgejo/kustomization.yaml | 1 + .../secret-cluster-backup-ssh.sops.yaml | 24 ++++++++++++ apps/base/sirius-growth/kustomization.yaml | 1 + .../secret-cluster-backup-ssh.sops.yaml | 24 ++++++++++++ clusters/homek8s/monitoring.yaml | 6 +++ docs/secrets-sops.md | 39 ++++++++++++++----- .../controllers/home/kustomization.yaml | 7 ++++ 7 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 apps/base/forgejo/secret-cluster-backup-ssh.sops.yaml create mode 100644 apps/base/sirius-growth/secret-cluster-backup-ssh.sops.yaml diff --git a/apps/base/forgejo/kustomization.yaml b/apps/base/forgejo/kustomization.yaml index 2a1dacd..d063d45 100644 --- a/apps/base/forgejo/kustomization.yaml +++ b/apps/base/forgejo/kustomization.yaml @@ -29,3 +29,4 @@ resources: - secret-forgejo-pg-app.sops.yaml - secret-forgejo-runner-amd64-token.sops.yaml - secret-forgejo-runner-deploy-arm64-token.sops.yaml + - secret-cluster-backup-ssh.sops.yaml diff --git a/apps/base/forgejo/secret-cluster-backup-ssh.sops.yaml b/apps/base/forgejo/secret-cluster-backup-ssh.sops.yaml new file mode 100644 index 0000000..6ff53f5 --- /dev/null +++ b/apps/base/forgejo/secret-cluster-backup-ssh.sops.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +data: + id_ed25519: ENC[AES256_GCM,data:amT/cj/RxpH62Bikn6MgHAZSud+3pzC80QgLFfbE7s83HPzndasB6HHG5FCjuhcU47IkyYwtpZXGa5BkAT5Ohidei6dV9+AbdLuTMer1UbIiPt5WQ6oUFysfTQrmwShbLH8imTr7j/xZ1/0gNpVrXGWjM4udKFqPoACR52JQsGSdH6dNleRyeZhxWmIiqwG5iFY8kJL4ARzTsjZNGCGVLalZFE+QKxiiQo+FTpjNMit+FNub4S8Q6lmHDHC5+gCLSOpJs+V1Jeijp7HCKQEzqgFzt3Gfj/HRHmmqQNHqB0OoP8+pJJ8dWxroHMf3zQv0DHj23Uer3zVpECzL3WInzLvGFq/E5CRbmDgPPaQJLTgy0YYdTwugBR6nf5PfjtJzeXV+EkoaNLsoywCdRwJ2HiT1B5dqZ0TsWu4WnyQzGev8fnfFsQcLxPTUcdhLKwqpFc0esScSPniRHgexR2A2HZqSQkpL5j2eAB/Hmsv9/632fd8iySliSISvwXb0Wv2T5BD5kQPMVqeWK6nmRWQeh2tI+IZbWUPSb6vSKgqQDNgtbL2m2uGV1rEMMdYONZrqzqPPwSWIK2QDoa2IhL50EvtQBk7/lFhVyYD/+k2zNc1jpptV/PTkWd3x4TMki/rVWBDIr87xkCMnAcx0+epMI9y07PpiEPO1OhG6GMNvDSO0B6UpN++RzouO2jgK649Kwk1Qsng9/jva4IasRxXon0biw4fxlKaWZR+pZyNmaSk=,iv:8sYhy8yMT59au1yHGhsfXFS9O4VXbYUMp6DNAjnUL+c=,tag:auvDjZ4Q+qVPNsGhHLkBYg==,type:str] + known_hosts: ENC[AES256_GCM,data:UHGQnYI70Gu3hEhwQKeilrvqNpQcrHyQHSO1Z079Ono6FzGR2yy+0vTBjvu8Jv9jiJKpBvs8INjXgN4RmBsOquuUsTt44Z6efVLZVlU8EsX/w7VIYdovFO5N43opOgeojhMZYb6BpdxF7oA7+VuG/J/AMHjAY2qKd/lESQ==,iv:KE/Nr2RiWFeS+jD289z07JHLxdSI6zqThrFkkmPJQEU=,tag:le8FwTGLY72La1/fiTeQJA==,type:str] +kind: Secret +metadata: + name: cluster-backup-ssh + namespace: forgejo +type: Opaque +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBENlJFaTFnbkJkMWdkSTdz + Rm03VFo2OG52NFQzRkZpa1ZNNHRiY1kva2dFCm01Vmc0YlFyRGZBUDMweTZrVzNH + YTJjY2YrTHV1VFNXSEM4b1hHcFFkSUUKLS0tIGdNOExKc3BldmFtYmpNcVNqTzk1 + VTM3ZEgyK1k0YldmejRERWVhK1BrakEKJQP4I7pCfLn5BYEwEb4I9K1fpYnKL4w+ + Jf3c1c+qNaaet9nDrP2WW1L6rug+K6iAkR1H6ywHVKH7Ue1Ft5T/Lw== + -----END AGE ENCRYPTED FILE----- + recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp + encrypted_regex: ^(data|stringData)$ + lastmodified: "2026-11-27T05:29:49Z" + mac: ENC[AES256_GCM,data:2RqTlxczkP9OHpqmjwdkOM3Ha68tIfvCnLOl/A2pqERR2bkxnWP87vVCKs3pZBZffQCU8NuK27yzBPSCHAPl4GUgt7QaUFHdHgsrbXIbDw1ZJ8ZVNLeIg2kLkJognhA1VOZZgL1oEKR+djBrqFJvHUWQfbkLrtoW5Rch/Qv+eDA=,iv:03IgpSHCqJuhFCykSjdqQhmoZfk6JNm4TxQtrtMY23E=,tag:Ln9PynG0Jll+0ZHC6D6l/w==,type:str] + version: 3.13.3 diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index a808d8f..1700824 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -38,3 +38,4 @@ resources: - secret-sirius-growth-portal-app.sops.yaml - secret-sirius-growth-portal-db.sops.yaml - secret-sirius-growth-portal-s3.sops.yaml + - secret-cluster-backup-ssh.sops.yaml diff --git a/apps/base/sirius-growth/secret-cluster-backup-ssh.sops.yaml b/apps/base/sirius-growth/secret-cluster-backup-ssh.sops.yaml new file mode 100644 index 0000000..2c0ad11 --- /dev/null +++ b/apps/base/sirius-growth/secret-cluster-backup-ssh.sops.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +data: + id_ed25519: ENC[AES256_GCM,data:WZ7KnBoV/semXMuMjKQ5AnuzKbJpbSHLjfsayHBvV9Q2IqL9N2/SmlaoZ3vdf/By2Yy2ayOFI/8/MkebY2vSuhGMtJaN3T4A3LEOCMSLfH0VcAQyfzInqLgF7rNPm+7C+FYSGAA5o2fqXwHzz5AlhNme7xYf4NK1hrnXen1T56uBm/dfXfvs2sJUaEuVq8XKQdnfkkWgXxDbk5SZlGJm/Aa0PpCDxHfoL1lAD6MOpgqKPWi6GDLTl1esiq/EqxUhpjoZo5NTnmaYX6IdaoPscrpvC5E4aGiYkihUsgyjkszLg1LjrsMZBLi0pwd1OWC7isRS2B+LOqetkXvCGtxg+0aaWmIBpZS4Y+G/lHK/WSY/QQsfynPwll5L9RtZtp022eeuLa/lnXyIrQQQLZNmzk7RVW+66twAXcymmV8HQRIdAGku4ZtJL3zEpH2yelN/TWi1bo7/+dtnElaa5bb29BrvP03Rb2GA5mNPtIhItgNOYCknkoXIWCVZ85x+60Ah+xa6R/HXRXRR5/D4+so5nDq2ISmZiq0FD7DEumU+WgvL0GyLsNkqRMl7BCGLeOzIuAO9lNuI/TZDcyOyS3eB0LIQNwdNU0FInJwJ4jp0yR3Cxd14hVATcjCU62zNQTmBHfXgAHLe1XUiUbs/ZxFcx5c36snRNot/jugwjMt0UDqgbwn2xqOvJxJT0hPYhf4u9SPH4VTLAbEE7DrwzNoPyb1I39wPeSLsPxBf4Or0cVw=,iv:oRzm1lCz7DDwF5616Hf+rRblPWJEc4ErHmoXLNvxoXQ=,tag:85h7JyO5wNUA89xIs5Pf1g==,type:str] + known_hosts: ENC[AES256_GCM,data:WAC8hq7IuinfG17Rhmr/F/bYZvviOkQwYpaAMdWnwNG7DrhehlN6x0HDCyVbuBWVMqTW4zva2K3tzWsZ8Ivv/xln8AsjSX3P31SWz6b38pyMPiYZ8lVtz449f84rftnb1KgIeYiTjv/5L5z4+Q/J2TR8UYLSwsi/K0G1Fw==,iv:MT20OcwHEA9zXPoloGaW8tGdbS7Kr+HrHMyk2UWByAY=,tag:s69nJ538DSqs/fTR5hgLtQ==,type:str] +kind: Secret +metadata: + name: cluster-backup-ssh + namespace: sirius-growth +type: Opaque +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB5ZC9CdER5b1ZXUDNISTF1 + VGllTmhDeHk5RUFkREd1UGM1bi9LRGxCNEFZCllSaS9ZOUtsU2N6TWlhemM1aXpS + elErcTE3K0ExYlVIYTBPczdnM2xuOG8KLS0tIDVDVm44UXhEYU84dktNK2I4L04x + VG1sdTVZVHZuWiswb3ljSWtoWWRDWjgKbUhCAclaS7Im9aqeX79VY/ZcJk/7oR6+ + z1TgPZbgJNjAeiKJIztQJrZLHwpqIB6kEYddof/tjlKk6i/epZ2ZGw== + -----END AGE ENCRYPTED FILE----- + recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp + encrypted_regex: ^(data|stringData)$ + lastmodified: "2026-11-27T05:29:49Z" + mac: ENC[AES256_GCM,data:1tTFNdkgjFiROm0XRqhmedhBqTolSc8oOCTW/QTmv20THC8XrRAt4gYbR3B6fFfzAcyp5I15/OtpPhopfma4VOGrXbShbHxbgKvaAcDWQWh/npwN2pbJJlIldyk0rWYEbRoAlzbDoq2TRfnqL5ejd67XkFQPsOhiWMhWlqfMzv4=,iv:T2rpa4hweAhPnBiUgw+xg2CGXkl2HoGCLGZ5pPSYJGk=,tag:FDat9gyykBOXJ2x2So1dyw==,type:str] + version: 3.13.3 diff --git a/clusters/homek8s/monitoring.yaml b/clusters/homek8s/monitoring.yaml index a4b2e17..ede2518 100644 --- a/clusters/homek8s/monitoring.yaml +++ b/clusters/homek8s/monitoring.yaml @@ -12,5 +12,11 @@ spec: name: flux-system path: ./monitoring/controllers/home prune: true + # Grafana's admin/secret-key, the Alertmanager Telegram bot token and the + # backup SSH key are committed as SOPS/age ciphertext (secret-*.sops.yaml). + decryption: + provider: sops + secretRef: + name: sops-age dependsOn: - name: infrastructure diff --git a/docs/secrets-sops.md b/docs/secrets-sops.md index b1f633d..57400c5 100644 --- a/docs/secrets-sops.md +++ b/docs/secrets-sops.md @@ -84,17 +84,24 @@ Ordering note: a Secret must exist before its consumer starts (CNPG `bootstrap.i `imagePullSecrets`, env refs). Kustomize sorts `Secret` before `Deployment`/`Cluster`, and all of these live in the same app directory, so one reconcile creates both. -## Inventory — in git (29 Secrets, 7 namespaces) +## Inventory — in git (35 Secrets, 8 namespaces) | Namespace | Secrets | |-----------|---------| -| `forgejo` | `forgejo-pg-app`, `forgejo-runner-amd64-token`, `forgejo-runner-deploy-arm64-token` | +| `forgejo` | `forgejo-pg-app`, `forgejo-runner-amd64-token`, `forgejo-runner-deploy-arm64-token`, `cluster-backup-ssh` | | `siriusdevops` | `siriusdevops-contact`, `garage-media-s3`, `forgejo-pull` | | `piedmont` | `piedmont-contact`, `forgejo-pull` | -| `sirius-growth` | `sirius-growth-contact`, `sirius-growth-blog-app`, `sirius-growth-blog-s3`, `sirius-growth-portal-app`, `sirius-growth-portal-db`, `sirius-growth-portal-s3`, `portal-wal-s3`, `forgejo-pull` | +| `sirius-growth` | `sirius-growth-contact`, `sirius-growth-blog-app`, `sirius-growth-blog-s3`, `sirius-growth-portal-app`, `sirius-growth-portal-db`, `sirius-growth-portal-s3`, `portal-wal-s3`, `forgejo-pull`, `cluster-backup-ssh` | | `osint` | `osint-admin`, `osint-db`, `forgejo-pull` | | `metabase` | `pg-app`, `metabase-admin`, `metabase-data-source-creds` | | `customer1` | `pg-app`, `pg-users`, `odoo-config`, `odoo-admin`, `metabase-admin`, `metabase-data-source-creds`, `metabase-secret-key` | +| `monitoring` | `grafana-admin`, `grafana-secret-key`, `alertmanager-telegram`, `cluster-backup-ssh` | + +`cluster-backup-ssh` is the same ed25519 key in three namespaces — a Secret cannot be +referenced across namespaces and each backup CronJob mounts its own namespace's copy, so there +are three files with identical plaintext (distinct ciphertext; age uses a random nonce). +Rotating it means updating all three. + `*-pg-app` / `pg-app` / `sirius-growth-portal-db` deserve a note: these look like CNPG output but are **ours** — each Cluster's `bootstrap.initdb.secret.name` points at one of them, so CNPG reads @@ -124,12 +131,24 @@ from starting, which is exactly what this card exists to prevent. It is a Forgej | `kube-prometheus-stack-prometheus-token` | `monitoring` | `kubernetes.io/service-account-token`, minted by the token controller. | | `flux-system` | `flux-system` | Git credential created by `flux bootstrap`; it authenticates the very pull that would apply it (chicken-and-egg), and rotating it is a bootstrap operation. | -Out of scope for this pass, tracked separately: `cluster-backup-ssh` (3 copies), `grafana-admin`, -`grafana-secret-key`, `alertmanager-telegram` live in `monitoring`/backup CronJobs and are being -migrated in a follow-up commit once the delete-and-reconcile drill below proved the path. +Now covered (added after the drill in the section below proved the recovery path): +`cluster-backup-ssh` (3 namespaces), `grafana-admin`, `grafana-secret-key`, `alertmanager-telegram`. -## Delete-and-reconcile drill (2026-11-27) +## Delete-and-reconcile drill (2026-11-27T05:29Z) + +Target: `siriusdevops/siriusdevops-contact` (Telegram token for the contact form — losing it for +a couple of minutes degrades one form, breaks nothing else). + +``` +05:28:59Z pre: pod Ready, /health {"ok":true}, keys TG_CHAT,TG_TOKEN, data sha256 1f17a3ac… +05:29:03Z kubectl -n siriusdevops delete secret siriusdevops-contact +05:29:05Z recreated by Flux (~2s, forced reconcile) — same keys, same data sha256 1f17a3ac… +05:29:11Z kubectl rollout restart deploy/siriusdevops-contact (prove env resolves from the + recovered Secret, not pod memory) +05:29:23Z rollout complete; new pod Ready, env TG_CHAT/TG_TOKEN present, /health {"ok":true} + both via localhost:8090 and via svc DNS + ClusterIP +``` + +Same key names before and after, byte-identical data, Secret back in the `apps` Kustomization +inventory. Only key **names** are recorded here. -`siriusdevops/siriusdevops-contact` — deleted, Flux recreated it from git, values verified -identical to the pre-delete snapshot, contact API still serving `/health`. Evidence in the -kanban card for `t_46f03ecb` (key names only, never values). diff --git a/monitoring/controllers/home/kustomization.yaml b/monitoring/controllers/home/kustomization.yaml index b878ed6..a52b618 100644 --- a/monitoring/controllers/home/kustomization.yaml +++ b/monitoring/controllers/home/kustomization.yaml @@ -14,6 +14,13 @@ resources: # Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users. - grafana-backup.yaml - dashboards + # Secrets, SOPS/age-encrypted in git (decrypted by the `monitoring` + # Kustomization; key = flux-system/sops-age). See docs/secrets-sops.md. + - secret-grafana-admin.sops.yaml + - secret-grafana-secret-key.sops.yaml + - secret-alertmanager-telegram.sops.yaml + - secret-cluster-backup-ssh.sops.yaml + configMapGenerator: - name: kube-prometheus-stack-values files: -- 2.52.0