new: secrets via SOPS in git, Owner roots in Vaultwarden (ADR-0008)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
BobbyandClaude Opus 5.5 committed 2026-11-24 15:08:56 -05:00
1 parent 3d8e3c7e6f
commit eb0022d94a
1 file changed
+33
+33
View File
@@ -0,0 +1,33 @@
# Secrets are SOPS-encrypted in the public repo; Owner roots live in Vaultwarden
Secrets the cluster needs are committed to this **public** repo, encrypted with **SOPS + age**, and Flux's kustomize-controller decrypts them as it applies them. Flux pulls with no git credentials and CI holds no cluster credentials (ADR-0007), so secrets must either ride in git encrypted or be placed by hand. Encrypting them in git keeps the cluster rebuildable from git plus one key, with no extra service to run. The roots of trust (the age key, the OpenTofu state key, the Linode and Object Storage tokens, talosconfig and kubeconfig) never enter the cluster or CI. They live in the Owner's self-hosted **Vaultwarden**.
## Considered Options
- **External Secrets Operator with a store** (Bitwarden Secrets Manager, 1Password, OpenBao). Rejected. It adds a third-party dependency or a service to run, and the cluster still needs its own credential for the store, so the bootstrap problem remains.
- **Sealed Secrets.** Rejected. The ciphertext still sits in git, and the controller's private key is generated in the cluster and has to be backed up, which makes disaster recovery worse than SOPS.
- **Secrets created by hand with `kubectl` over the tailnet.** Rejected. Nothing records what should exist, drift goes unnoticed, and rebuilding the cluster needs a manual step for each secret.
## Consequences
- **The ciphertext is public forever.** Key names and encrypted values can be read by anyone, along with every past version in history. If the age key is ever exposed, **every value it protected is rotated**. Replacing the key alone isn't enough.
- **Layout:** `.sops.yaml` encrypts only `data`/`stringData` in `deploy/**/*.sops.yaml`. The Flux Kustomizations that carry secrets set `decryption.provider: sops`.
- **The age key:** there is one, for prod, generated offline. Its durable copy is in Vaultwarden. During the Flux install runbook, the Owner creates `flux-system/sops-age` from it by hand. OpenTofu never sees it, so it stays out of Tofu state.
- **Secrets reach the app as files, never env vars.** They're mounted read-only under pydantic-settings' `secrets_dir`. Env vars leak through `/proc`, into child processes such as break-glass `psql`, and into debug output. Non-secret config such as the DB CA certificate is committed in plaintext as a ConfigMap.
- **DB credentials are split** (ADR-0004):
- `hapi-db-app` is mounted only into the app Deployment, which also hosts the admin CLI.
- `hapi-db-migrator` is mounted only into the migrate Job and a runbook admin pod used for `hapi db bootstrap` and `hapi db breakglass`.
- No workload ServiceAccount can read Secrets.
- **Git is the source of truth for DB passwords.** The Owner generates them and commits them encrypted. The idempotent `hapi db bootstrap` reads them from its mounted files and runs `CREATE`/`ALTER ROLE … PASSWORD`. The `akmadmin` password is still pasted in at run time and never stored in git or the cluster.
- **Each integration gets its own narrow credential:**
- The CCM gets a dedicated Linode token with only the scopes it needs. OpenTofu creates it, never reusing the Owner's Tofu token.
- Later credentials (DNS-01, ntfy, the backup target) are each a narrow token delivered through SOPS.
- **CI secrets** (the write deploy key, the Renovate bot token, a publish-only ntfy token for the CI topic) are repo-level Gitea Actions secrets. CI never decrypts SOPS.
- **Guardrails against plaintext:**
- gitleaks runs in pre-commit and as a required CI check.
- A second CI check fails on any `kind: Secret` manifest without SOPS metadata, or any `*.sops.yaml` that isn't encrypted.
- A plaintext secret that reaches `main` is rotated. Rewriting history doesn't help, because clones and caches already have it.
- **Rotation is manual and event-driven**, with no schedule. It happens on suspicion of exposure, when the age key is exposed, or when who has access changes.
- **For a DB password:** merge the new SOPS value, wait for Flux, run `hapi db bootstrap` (which runs `ALTER ROLE`), then `kubectl rollout restart`.
- **The cost:** new connections fail for a few seconds between the last two steps, which is accepted. There's no Reloader controller.
- **Owner roots:** kubeconfig and talosconfig sit on local disk only while in use. Vaultwarden is cloud-hosted with its own backups. An additional offline copy (paper or encrypted USB, kept away from home) holds the age key, the OpenTofu state passphrase and the Linode account recovery codes, and is updated whenever one of them rotates.