Lab & Completion
What You Will Produce
On your own kind cluster, a Secret encrypted with your key travels the whole path: your editor, ENC[...] in your fork, decrypted by secrets-local into develop - where it is plaintext again. Then you reproduce the incident: the sops-encrypted check refuses a plaintext Secret before it can be committed. A file encrypted for a key your cluster does not hold stops secrets-local until you re-encrypt it. Last, you rotate your age key through Terraform - both keys during the transition, sops updatekeys and sops rotate, then the old key out - and prove that the old key opens nothing new, but still opens your old commit. The lab commits to your fork and ends with the lab Secrets removed.
Before You Start
The baseline from Chapter 00 must be clean:
flux --context kind-sre-control-plane get kustomizations -A # every row READY=True and SUSPENDED=False
kubectl --context kind-sre-control-plane get pods -A --no-headers | grep -vE 'Running|Completed' # prints nothing
make smoke-test # Fail: 0
This chapter also needs:
- Flux following your fork (
flux_git_repository_urlinterraform.tfvars, Chapter 00) - B3 plans and applies Terraform with it; - your key registered:
scripts/sops-setup.sh --localand.sops.yamlcommitted (Chapter 00); sops,ageandpre-commitinstalled (make check-tools).
The Lab in Three Parts
- A. Verify - Flux follows your fork; your key is the same in
age.agekey,.sops.yamland the cluster;secrets-localdecrypts; a Secret you encrypt arrives indevelop. - B. Break & Fix - a plaintext Secret refused by the check; a file for a foreign key that stops
secrets-local, fixed by re-encrypting; a full rotation of your age key through Terraform. - C. Rollback & Cleanup - the lab Secrets removed through Git and pruned by Flux; the baseline and
make kind-driftproven.
Done When
-
age-keygen -y age.agekeyand theflux/secrets/local/rule in.sops.yamlprinted the same key, andscripts/sops-setup.sh --localsaid the cluster holds it (A3) -
flux/secrets/local/lab-secret.yamlshowedgreeting: ENC[AES256_GCM,..., and the Secret indevelopdecoded tohello from my key(A5) -
pre-commit run sops-encryptedprintedFailedandNOT ENCRYPTED: flux/secrets/local/lab-plain.yaml, and nothing was committed (B1) - with
lab-wrong-keyencrypted for the other key,secrets-localwasREADY Falsewithidentity did not match any of the recipients, whilelab-secretstayed (B2) - after
sops updatekeyswith the other key,secrets-localwasREADY Trueandlab-wrong-keyexisted (B2) - both rotation plans showed exactly
Plan: 0 to add, 1 to change, 0 to destroy.- the in-place update ofkubernetes_secret_v1.sops_age(B3) -
updatekeys: value unchanged - same data key,rotate: value re-encrypted - new data key, andold key, new file: exit=128, while the old key still opened A5’s commit (B3) - with only the new key in the cluster,
flux reconcile kustomization secrets-localprinted✔ applied revision(B3) - at the end,
lab-secretandlab-wrong-keyareNotFound, the baseline is clean,make kind-driftreturns0,git status --shortprints nothing, andls *.agekeylists onlyage.agekey(C1-C2)
Knowledge Check
Before finishing this chapter, complete the Quiz.