Secret Encryption at Rest
What you'll learn: How to configure Kubernetes to encrypt Secret data stored in etcd so it's protected even if someone gains direct access to your cluster's database.
What "At Rest" Means
By default, Kubernetes stores Secrets in etcd (the cluster's key-value database) as base64-encoded text—which is not encrypted. Anyone with direct access to etcd can decode and read your sensitive data. "Encryption at rest" means encrypting data when it's stored on disk, protecting it from unauthorized physical or database-level access.
Think of it like keeping your valuables in a locked safe inside your house, rather than just hiding them under the mattress. Even if someone breaks into your house (gains etcd access), they still can't open the safe without the key.
How It Works
You configure an EncryptionConfiguration file on the Kubernetes API server that specifies:
- Which encryption provider to use (like
aescbc,aesgcm, or external KMS) - The encryption keys to protect Secret data
- The resources to encrypt (usually
secrets)
When you apply this configuration and restart the API server, all new Secrets are encrypted before being written to etcd. Existing Secrets remain in their old format until you manually re-encrypt them by updating each Secret.
# Example structure (not runnable yet at this stage)
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
- secrets
providers:
- aescbc:
keys:
- name: key1
secret: <base64-encoded-32-byte-key>
You pass this file to the API server with --encryption-provider-config flag.
Key Takeaway: Encryption at rest protects Secret data stored in etcd from unauthorized access by encrypting it with provider-defined keys before writing to disk, adding a critical security layer to your cluster's sensitive data.