Interview Prep/Kubernetes/Configuration, Secrets and storage

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 →

  1. Create an EncryptionConfiguration with a kms provider (AWS KMS v2) first and identity last
  2. Pass it with --encryption-provider-config on kube-apiserver (on EKS enable envelope encryption in the cluster)
  3. Re-encrypt existing data: kubectl get secrets -A -o json | kubectl replace -f -
  4. Rotate by adding the new key first, restart apiservers, re-encrypt, then remove the old key
  5. Verify with etcdctl get showing the k8s: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.

All Kubernetes questions Roadmap: Kubernetes core

More on Configuration, Secrets and storage