Why Use Kubernetes Secrets?
Managing sensitive data—passwords, API tokens, SSH keys—is critical in any deployment. Kubernetes Secrets help you:- Decouple credentials from application pods and container images
- Store sensitive values centrally in etcd (the Kubernetes key-value store)
- Consume secrets as mounted volumes or environment variables
Kubernetes Secrets are only base64-encoded, not encrypted by default. Any user with API or etcd access can decode them.
Creating a Generic Secret
Create a simple Secret in one command:Viewing Secrets Directly in etcd
With etcd client certificates, stored Secrets appear in plain text:Mitigation: Encryption at Rest
Kubernetes supports encrypting Secrets in etcd with anEncryptionConfiguration.
-
Create
/etc/kubernetes/pki/encryption-config.yaml: -
Update the API server flags:
- Restart the kube-apiserver. All new Secrets will be encrypted in etcd.
To encrypt existing Secrets, run: