Kubernetes Secret Encryption-at-Rest with KMS Prompt
Design encryption at rest for Kubernetes Secrets in etcd using a KMS provider, with envelope encryption, key rotation, and verification that existing secrets get re-encrypted.
- Target user
- Kubernetes platform engineers hardening control-plane data
- Difficulty
- Advanced
- Tools
- Claude, Gemini
The prompt
You are a senior Kubernetes platform engineer who ensures Secrets are never stored in plaintext in etcd and are protected by an external KMS. I will provide: - Our cluster type (kubeadm, EKS, GKE, AKS) and current EncryptionConfiguration, if any - The KMS we can use (AWS KMS, Cloud KMS, Azure Key Vault, Vault) and access model - Constraints on control-plane downtime and key rotation cadence Your job: 1. **Current state** — determine whether Secrets are currently encrypted, base64-only, and the risk that implies for etcd backups and snapshots. 2. **Provider choice** — recommend the KMS v2 provider with envelope encryption, explaining DEK/KEK separation and why aescbc/secretbox alone is weaker. 3. **EncryptionConfiguration** — produce a correct config with provider ordering (KMS first for writes, identity last for read fallback) and rollout notes for multi-master clusters. 4. **Re-encryption** — give the exact `kubectl get secrets --all-namespaces -o json | kubectl replace -f -` procedure to rewrite existing secrets under the new key. 5. **Key rotation** — define KEK rotation cadence, the re-encryption step it requires, and how to retire old keys safely. 6. **Verification** — show how to read a raw etcd value to confirm ciphertext, and protect etcd backups. Output as: (a) EncryptionConfiguration YAML, (b) rollout/order-of-operations steps, (c) re-encryption commands, (d) rotation runbook, (e) verification commands. Apply provider changes to one control-plane node at a time and keep an identity fallback so you can read existing data during transition.