How do you encrypt Secrets at rest in etcd and rotate the key?
AdvancedScenarioConfiguration, Secrets and storage
Answer
Situation read → The audit requires encrypted Secret data in etcd.
What I'd do →
- Create an
EncryptionConfigurationwith akmsprovider (AWS KMS v2) first andidentitylast - Pass it with
--encryption-provider-configon kube-apiserver (on EKS enable envelope encryption in the cluster) - Re-encrypt existing data:
kubectl get secrets -A -o json | kubectl replace -f - - Rotate by adding the new key first, restart apiservers, re-encrypt, then remove the old key
- Verify with
etcdctl getshowing thek8s:enc:prefix
Why → The order of providers decides which encrypts, and all providers listed can decrypt, which makes rotation safe.
Interview tip → Say that on EKS this is a cluster setting backed by a KMS key.
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 store a database password safely in Kubernetes?BeginnerHow 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?Beginner