๐Ÿ“– Read-only preview โ€” lessons, diagrams, and quizzes only. The hands-on labs, live grading, and progress tracking require running the real course locally against a Kubernetes cluster.Run it locally โ†’

Module 5 ยท Lesson 5.2

Secrets

Mechanically, almost the same object

A Secret is consumed exactly like a ConfigMap โ€” env var via secretKeyRef, envFrom, or a mounted volume. If you understood the last lesson, you already know how to use one. The only real differences are in what Kubernetes does with the data, and what you should assume about it.

base64 is not encryption

Open a Secret with kubectl get secret <name> -o yaml and the values are base64-encoded strings, not the plain text you wrote. It is extremely common to mistake this for security. It isn't: base64 is just an encoding โ€” a reversible way to represent arbitrary bytes as plain text (the same trick email attachments have used for decades), not a cipher. Anyone who can read the Secret object through the API can decode it in one command: echo '<value>' | base64 -d. No password, no key, nothing to crack.

Linux aside: encodings like base64 translate data into a different representation with no secret involved โ€” reversible by anyone, by design. Encryption transforms data using a key, reversible only by whoever holds that key. Confusing the two is one of the most common security misunderstandings in infrastructure work generally, not just Kubernetes.

What actually protects a Secret

Real protection comes from layers outside the Secret's own encoding:

  • RBAC restricting who can get/list Secret objects at all โ€” the thing actually worth getting right (Module 11).
  • Encryption at rest for etcd itself, so a stolen disk doesn't hand over every Secret in the cluster โ€” a cluster-operator-level setting, not something you configure per-Secret.
  • In real production, often an external secret store (AWS Secrets Manager, Vault) with Kubernetes only holding a short-lived reference โ€” exactly what Module 15 touches on for EKS.

None of that is "turn on a flag on the Secret" โ€” it's about everything around the Secret.

The infrastructure analogy

Treat a Kubernetes Secret the way you'd treat a value sitting in a shared password vault with weak access controls: fine for convenience, not a substitute for actually restricting who's allowed to open the vault. The object type's name is aspirational, not a guarantee.

In the lab, you'll wire a Secret into a Pod and fix a realistic typo โ€” a Secret key name that doesn't match what the Pod expects โ€” the same failure mode as the ConfigMap lab, just one object type over.

๐Ÿงช Lab: lab-10-secrets

Preview only

Goal

Wire a Secret into a Deployment, see for yourself that it's just encoded (not encrypted), and fix the same kind of key-mismatch bug as the ConfigMap lab โ€” one object type over.

Tasks

  1. Apply the starting manifests: kubectl apply -f manifests/
  2. Look at the live Secret: kubectl get secret db-creds -n lab-10-secrets -o yaml. The value isn't the plain text you wrote in manifests/secret.yaml โ€” decode it yourself: echo '<the base64 value>' | base64 -d. No password, no key, just text transformed back and forth.
  3. Check the pod: kubectl get pods -n lab-10-secrets. Not Running โ€” same CreateContainerConfigError failure mode as the ConfigMap lab.
  4. kubectl describe pod -n lab-10-secrets -l app=app โ€” read the Events.
  5. Fix it: edit manifests/deployment.yaml so secretKeyRef.key matches a key that actually exists in the Secret, then kubectl apply -f manifests/deployment.yaml again.
  6. Confirm: kubectl exec -n lab-10-secrets deploy/app -- printenv DB_PASSWORD prints the Secret's value.

Check

Run the check once the pod is Running and DB_PASSWORD resolves correctly inside the container.

This lab runs against a real local Kubernetes cluster with an automated grader โ€” clone the repo and run make start to do it for real.

๐Ÿ“ Quiz

1. You run `kubectl get secret db-creds -o yaml` and see base64 text instead of your original password. What does that base64 encoding actually provide?scenario

2. What's the real difference between a ConfigMap and a Secret from the Pod's point of view?

3. Which of these actually improve Secret security? (select all that apply)

4. A Pod references secretKeyRef with key 'password', but the Secret's actual key is 'db_password'. What happens?scenario

5. Where does Module 11 (RBAC) connect back to this lesson?

Progress isn't saved in this preview โ€” run the course locally to track completion and grade labs for real.