Sealed Secrets
Bitnami sealed-secrets is the only commit-safe way to ship Kubernetes
Secrets through this repo. kubeseal reads the live cluster's public
key and encrypts secret data into a committed *-secret.yaml file that
the in-cluster controller decrypts into a real Secret.
kubeseal is one of the few commands allowed to touch the live cluster
directly (see CLAUDE.md hard rules).
File naming
- SealedSecret files must be named
*-secret.yaml(singular).
*-secrets.yaml is not in the .gitleaks.toml allowlist — the
pre-commit hook will block the commit with no obvious reason.
The placeholder base64 foot-gun
**Never commit a *-secret.yaml with placeholder text like REPLACE_ME
in encryptedData.** The chain of silent failures is brutal:
- Controller fails to decrypt:
illegal base64 data - The real
Secretis never created - Any Prometheus operator CR (Alertmanager / Prometheus) referencing
the missing Secret via secrets: silently omits the volume mount
- You get runtime errors that don't obviously point at the placeholder
Always seal a real value immediately, or omit the file entirely
until you have one. If you must stub it out, use a short real string
and reseal later — never a literal REPLACE_ME.
`scripts/seal-argocd-dex` — per-secret subcommands
seal-argocd-dex needs a subcommand; a bare run prints usage and exits 1:
seal-argocd-dex <github|argocd|monitor|grafana>
Full sealing is just generate-and-seal-all (the rebuild path).
Subcommands read existing keys from the running argocd-dex-secret to
preserve values they don't touch, so it must already exist.
Pod restarts after reseal
Pods that read secret values via envFrom or secretKeyRef **cache
values at pod startup**. After re-sealing, running pods keep stale
values and OAuth/service login fails with errors like
invalid client_secret — even though the Kubernetes Secret object
itself is correct.
seal-argocd-dex does not restart anything. After a reseal, restart
only the pods that consume the secrets you changed, from these namespaces:
argo-cd(just restart-dex) /argocd-monitor
(kubectl -n argocd-monitor rollout restart deployment)
ntfy— delete the pod, do not just restart the container:
kubectl delete pod -n ntfy -l app.kubernetes.io/name=ntfy. The user
database is on the pod's emptyDir, and only a new pod drops the old
tokens and any minted through the account API (docs/how-to/ntfy.md)
monitoring(kubectl rollout restart sts grafana-prometheus -n monitoring)scrap(kubectl -n scrap rollout restart deploy/scrap), e.g. after
just seal-ntfy --rotate scrap (it reads SCRAP_NOTIFY_URL at start)
headlampcloudflared(kubectl -n cloudflared rollout restart deployment/cloudflared;
reseal its token with just cf-seal-tunnel-token)
`cookie-secret` generation
oauth2-proxy's cookie secret must be exactly 16, 24, or 32 bytes
for the AES cipher. Regressions have happened twice:
base64.b64encode(token_bytes(32))→ 44 chars → oauth2-proxy crash- Use
secrets.token_hex(16)(32 hex chars = 32 bytes) — this is what
scripts/seal-argocd-dex does. Do not change it.
Non-deterministic re-encryption
kubeseal adds random padding, so re-sealing the same plaintext
produces a different ciphertext each run. This is expected. Don't try
to diff-match sealed ciphertexts — diff the underlying plaintext via
the generator script or compare decrypted Secret contents on-cluster.
Sealing keys: renewal off, backed up nightly
- Automatic key renewal is off (
keyrenewperiod: "0"in
kubernetes-services/templates/sealed-secrets.yaml), so the key changes
only on a manual rotation or a rebuild. To rotate, set the chart's
keycutofftime (date -R) through Git; the controller makes a new key
when it restarts. Then optionally kubeseal --re-encrypt the repo's
SealedSecrets. See docs/how-to/manage-sealed-secrets.md.
- The nightly
k3s-etcd-backupjob exports the key Secrets, age-encrypted,
to backups/etcd/sealed-secrets-keys.yaml.age on the NAS. Never write
the decrypted keys to disk or print them; pipe age -d straight into
kubectl apply -f - or kubeseal --recovery-private-key <(...).
- After a rebuild or rotation the user's offline key copy is stale:
remind them to re-export it (docs/how-to/backup-restore.md).
Key files
scripts/seal-argocd-dex— main Dex/OAuth sealing entry pointscripts/seal-from-json— batch sealing from/tmp/cluster-secrets/kubernetes-services/additions/*/-secret.yaml` — committed sealed secrets