Guardrails That Stop It
- No Plaintext in Git: Any file under
flux/secrets/must be encrypted. sops-ageSecret: Must exist in theflux-systemnamespace for decryption to work.no-secretsHook: Local pre-commit hook that blocks files likekubeconfigor.env.flux-kustomize-validateHook: Ensures your secret wiring is syntactically correct before commit.
Safe Workflow (Step-by-Step)
- Verify Prerequisites: Ensure
sopsandageare installed locally. - Check for Key: Ensure the
sops-agesecret exists in your cluster:kubectl -n flux-system get secret sops-age - Create Secret: Use the helper script to create and encrypt your secret:
scripts/sops-encrypt-secret.sh develop backend-secrets - Update Kustomization: Add the new
.yamlfile toflux/secrets/develop/kustomization.yaml. - Commit and Push: Add the encrypted file and the kustomization update to Git.
CI/Logs Guardrails
- Never print secrets: Avoid
echo $SECRETin CI pipelines. - No verbose traces: Do not use
set -xin scripts that handle secrets. - Check existence only: Verify that a secret exists without dumping its values:
kubectl -n develop get secret backend-secrets -o name
Key Rotation
To rotate your Age keys and re-encrypt secrets:
- Generate a new key:
age-keygen -o age-new.agekey. - Update
.sops.yaml: Replace the old public key with the new one. - Re-encrypt: Run
sops rotate --in-place <file>for every secret. - Update Cluster: Delete and recreate the
sops-agesecret influx-system.
This builds on: IaC workflows (Chapter 02) — secrets are part of the state model. This enables: GitOps (Chapter 04) — Flux decrypts secrets inside the cluster.