Sub topic 1
Why secrets need to live outside your manifests
Prerequisites
This chapter assumes you can:
- Use
kubectland know the basic Kubernetes objects: Pods, Secrets, namespaces and ServiceAccounts. - Read and write YAML manifests.
- Run basic Helm commands.
- Describe what a cloud secret manager does, such as AWS Secrets Manager or HashiCorp Vault.
The problem with Secrets in Git
Kubernetes has a built-in Secret object. It holds passwords, tokens and keys, and Pods can read it as environment variables or files. The trouble starts when you try to manage that object the way you manage everything else, which is as a manifest in Git.
Here is a typical Secret manifest:
apiVersion: v1
kind: Secret
metadata:
name: db-credentials
namespace: app
type: Opaque
data:
password: czNjcjN0LXBhc3N3b3JkThe data values look scrambled, but they are only base64 encoded. Base64 is a way to write bytes as text. It is not encryption, and anyone can reverse it:
echo 'czNjcjN0LXBhc3N3b3Jk' | base64 -dThis prints s3cr3t-password. If this file is committed, the password is readable by everyone with access to the repository.
What goes wrong
Committing secrets causes several concrete problems:
- History keeps them. Deleting the file in a later commit does not remove the value from earlier commits, clones and forks.
- Access spreads. Anyone who can read the repository can read production credentials, including CI systems and contractors.
- Rotation is manual. Changing a password means editing a manifest, committing, and deploying again, for every cluster that uses it.
- Copies drift. The same credential pasted into several repositories or clusters gets updated in some places and missed in others.
- Auditing is weak. Git records who edited a file, not who read the secret or when.
Encrypting secrets in Git, with tools such as Sealed Secrets or SOPS, reduces the exposure. The encrypted value is still stored in the repository, and rotation is still a commit.
The alternative: one source of truth outside the cluster
A dedicated secret manager stores the value once. It encrypts it at rest, controls access with its own policies, writes audit logs, and supports rotation. Git then holds only a reference, such as "the password property of prod/db", and never the value itself.
Something still has to turn that reference into a native Kubernetes Secret, because Pods consume Secrets, not cloud API calls. External Secrets Operator (ESO) does this. It runs in the cluster, reads the reference from a custom resource, fetches the value from the provider, and writes a regular Secret. It then re-reads the value on a schedule, so rotation in the provider reaches the cluster without a redeploy.
What this does not solve
The synced object is still an ordinary Kubernetes Secret. It is stored in etcd, and anyone with RBAC permission to read Secrets in that namespace can decode it. ESO moves the source of truth and automates delivery. It does not make the in-cluster copy invisible. Later chapters cover etcd encryption, RBAC and least-privilege store access.
Exercise
Exercise
A teammate says a Secret manifest is safe to commit because its values are base64 encoded. Give two reasons this is wrong, and say what you would commit to Git instead when using ESO.
Show answer
Base64 is reversible encoding, not encryption, so anyone with the file can decode the value with base64 -d. Also, Git history keeps the value even after the file is deleted or changed, so rotating the password does not remove the old one from earlier commits. With ESO you commit an ExternalSecret that references the remote secret by key and property. The password itself stays in the external secret manager.