Chapter 04: Secrets Management (SOPS + Age)
Learning Objectives
By the end of this chapter, you will be able to:
- Encrypt a Secret with SOPS and age before it is committed, and trace it to the Secret Flux applies in the cluster
- Name every place a secret value exists in plaintext - and the one place SOPS protects
- Respond to a pushed plaintext secret: replace it at its source first, clean up Git second
- Rotate an age key so that the old key opens nothing new: new key,
sops updatekeys,sops rotate, Terraform
Recall Check
Before continuing, quickly recall:
- Why is a value marked
sensitivein Terraform still not a secret, and how does the SOPS key reach the cluster without being stored in the plan? (Chapter 02) - Which Flux Kustomization decrypts, and which Secret does it read the key from? (Chapter 03)
- What does Flux do at the next reconcile with a value someone changed by hand in an object it manages? (Chapter 03)
If you can’t answer these, revisit the corresponding chapter before proceeding.
Context
The platform repository is public. Everything Flux applies comes from it (Chapter 03) - and that includes the backend’s database password, the Cloudflare API tokens and the Dex client secret. They are in Git, under flux/secrets/, readable by anyone - as ciphertext. SOPS encrypts the values of each Secret with an age key before they are committed; Flux decrypts them inside the cluster with the private key Terraform put there as flux-system/sops-age.
That only works if nobody ever pushes a value unencrypted, and if the private key stays private. Both have gone wrong on real platforms - this one included: in September 2026 its age key leaked through a CI artifact (Chapter 02), and every value encrypted for it had to be replaced. This chapter is about the two guardrails that keep values encrypted, about where they still are plaintext, and about what to do when one leaks anyway: revoke and replace it where it is issued - not in Git.
Work through each lesson section; the chapter video, once it is published, gives the concept overview.
How a Secret Travels from Your Editor to a Pod
SOPS protects one stop on this path: Git. Before it, the value is on your machine; after it, it is a normal Kubernetes Secret, protected by RBAC, not by encryption.