Core Track Guardrails-first chapter in core learning path.

Estimated Time

  • Reading: 25 min
  • Lab: 45 min
  • Quiz: 5 min

Prerequisites

What You Will Produce

On your own kind cluster: a Secret encrypted with your key in flux/secrets/local/ that Flux decrypts into develop; a plaintext Secret the sops-encrypted hook refuses before it can be pushed; a file encrypted for a key the cluster does not hold, which stops secrets-local until you re-encrypt it; and a full rotation of your age key through Terraform, after which the old key opens nothing new. The lab ends with every Kustomization Ready and none suspended, and make kind-drift returning 0.

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 sensitive in 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

Diagram: your machine; your editor plaintext, in a private temp file; sops --encrypt with the public key from .sops.yaml; Git - public; values ENC[...] names and keys readable; the cluster; kustomize-controller decrypts in memory with sops-age; Secret in develop base64 = plaintext to anyone who may read it; pod env or file plaintext

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.


Detailed Lessons

Hands-On Materials

Labs, quizzes and runbooks for this chapter are free - sign in with your email, Google or GitHub to open them.

  • Lab: Encrypted Before It Leaves Your Machine Free · sign in
  • Quiz: Chapter 04 (Secrets Management with SOPS) Free · sign in