How do you store a database password safely in Kubernetes?
BeginnerScenarioConfiguration, Secrets and storage
Answer
Situation read → A repo contains a plain-text password in a manifest.
What I'd do →
- Rotate the exposed password immediately
- Store it with
kubectl create secret generic db --from-literal=password=...or better through an external manager - Use External Secrets Operator or the Secrets Store CSI driver with AWS Secrets Manager
- Mount as a file or env var in the pod
- Enable encryption at rest for etcd and restrict Secret RBAC
Why → Secrets are base64 encoded, not encrypted, so the real protection is encryption at rest, RBAC, and keeping values out of Git.
Interview tip → Say "base64 is not encryption" early.
More on Configuration, Secrets and storage
How do you inject configuration into pods and what are the options?BeginnerA ConfigMap was updated but the pod still shows old values. Why?IntermediateHow do you manage secrets in GitOps without committing them in plain text?IntermediateA pod fails with `CreateContainerConfigError` and a missing key. What happened?BeginnerWhat is the difference between emptyDir, hostPath, PV/PVC and when do you use each?BeginnerA StatefulSet's PVC stays Pending. How do you debug?Intermediate