Lab: Encrypted Secret -> Flux Decrypt -> Cluster Apply
Goal
Execute a safe secrets workflow for develop:
- create/update encrypted secret manifest with SOPS
- commit only encrypted content
- verify Flux decrypts and applies secret in-cluster
Guardrail Companion
README.md(incident context and safe path)flux/secrets/README.md(SOPS/age mechanics)
Prerequisites
sops,age,kubectlinstalledpre-commitinstalled with hooks from this repo (make install-hooks)- access to a cluster with Flux installed
flux-systemnamespace existssops-agesecret exists influx-system
Quick checks:
command -v sops
command -v age
kubectl get ns flux-system
kubectl -n flux-system get secret sops-age
Step 1: Context Check
pwd
ls -la flux/secrets/develop
Expected:
- you are in
sre/ flux/secrets/develop/kustomization.yamlexists
Step 2: Create or Update Encrypted Secret
scripts/sops-encrypt-secret.sh develop backend-secrets
Expected:
- file exists:
flux/secrets/develop/backend-secrets.yaml - file contains encrypted fields (
ENC[), not plaintext values
Step 3: Wire Secret into Kustomization
Edit flux/secrets/develop/kustomization.yaml and ensure:
resources:
- uptrace-secrets.yaml
- backend-secrets.yaml
Hard stop conditions (do not commit):
- any plaintext secret value in
backend-secrets.yaml - committed
age.agekeyor any private key material - wrong namespace in secret metadata
Step 4: Commit Encrypted Changes
git add flux/secrets/develop/backend-secrets.yaml flux/secrets/develop/kustomization.yaml
git diff --cached
Review expectation:
- encrypted payload only (
ENC[...]) - no plaintext credentials in staged diff
Then:
pre-commit run no-secrets --all-files
pre-commit run flux-kustomize-validate --all-files
git commit -m "chapter-03: add/update encrypted backend secret for develop"
git push
Step 5: Verify Flux Reconciliation
kubectl -n flux-system get kustomization secrets-develop
kubectl -n flux-system describe kustomization secrets-develop
kubectl -n develop get secret backend-secrets
Expected:
secrets-developisReady=True- secret
backend-secretsexists in namespacedevelop
Failure Scenarios
- Missing
sops-agesecret
- symptom: decryption/reconcile errors in
secrets-develop - action: create key secret in
flux-system, then reconcile again
- Secret file not referenced in kustomization
- symptom: Flux healthy, but
backend-secretsnot created - action: add
backend-secrets.yamltoflux/secrets/develop/kustomization.yaml
- Plaintext committed by mistake
- symptom: sensitive data visible in Git diff/history
- action: incident response flow (rotate credential, purge/contain exposure, audit access)
Done When
- learner can complete
encrypt -> commit -> Flux decrypt/applyindevelop - learner can explain why encrypted-at-rest in Git is mandatory
- learner can diagnose the three failure scenarios above