How to show Kubernetes Secrets are encrypted at rest

Encryption at rest for Secrets is off by default, so the evidence has to prove that it is on. Show an auditor three things from the cluster: the kube-apiserver loads an EncryptionConfiguration whose first provider is not identity, a new Secret is stored in etcd with that provider’s prefix, and existing Secrets have been rewritten since the change.
What the API server stores by default
The API server writes resource data to etcd as plain text unless you configure encryption. The encryption task page says this at-rest encryption is additional to any system-level encryption for the etcd cluster or for the filesystems on hosts that run kube-apiserver. Disk encryption therefore does not stand in for it. The scope is API resource data, such as the key-value data in Secret objects.
Base64 is not protection. The Secrets good-practices page says Secret values are base64 encoded and stored unencrypted by default, and that base64 “provides no additional confidentiality over plain text.” When an auditor sees base64 in an export, read it as plain text.
This post was checked against the kubernetes.io pages listed at the end, fetched 2026-11-28. The KMS provider page states that it describes Kubernetes 1.37. The encryption task page gives version floors: custom resources need v1.26 or newer, wildcards need v1.27 or newer, and the control plane must use etcd v3.x.
Compare the providers
The providers differ in strength, where the key lives and what the page recommends. Use this table to pick one, and to explain the choice in your evidence file.
| Provider | Strength (per the page) | Where the key lives | Page guidance |
|---|---|---|---|
| identity | None. Resources are written as-is | Not applicable | The default. Remove it once all Secrets are encrypted |
| aescbc | Weak. AES-CBC with PKCS#7 padding | On the control plane host | Not recommended because of padding oracle attacks |
| aesgcm | AES-GCM with random nonce. Rotate every 200,000 writes | On the control plane host | Only with an automated key rotation scheme |
| secretbox | Strong. XSalsa20 and Poly1305 | On the control plane host | May not be acceptable where review requirements are high |
| kms v1 | Strongest. DEK per resource | Remote KMS | Deprecated since v1.28 and disabled by default from v1.29 |
| kms v2 | Strongest. DEK per API server | Remote KMS | Stable since v1.29. The page recommends it |
Check whether encryption is already on
Start by reading the cluster. The page gives three checks on the kube-apiserver static Pod and the file it references.
- Open the kube-apiserver static Pod manifest. The page’s example path is
/etc/kubernetes/manifests/kube-apiserver.yaml. If the kube-apiserver has no--encryption-provider-configargument, the page says at-rest encryption is not enabled. - If the argument is present, open the file it names. If the first provider in the list for
secretsisidentity: {}, at-rest encryption is not enabled, because identity stores data as plain text. - If the first provider is anything else, encryption is on. The page adds that this check does not show whether an earlier migration to encrypted storage finished. Run the verification and re-encryption steps below before you tell an auditor that existing Secrets are covered.
- --encryption-provider-config=/etc/kubernetes/enc/enc.yaml
Choose local keys or a KMS provider
The page separates two key storage models. With local keys, the key sits in the EncryptionConfiguration file on each host. The page says that protects against an etcd compromise but not a host compromise, because an attacker who reads the file can extract the keys. With KMS, the key encryption key stays in a remote KMS, and the API server stores an encrypted data key in etcd next to each ciphertext.
Use KMS v2 for managed keys
The page recommends KMS v2 over v1 and says it performs better. The KMS plugin is a gRPC server that listens on a UNIX domain socket and runs on the same hosts as the control plane. The API server polls the plugin’s Status call about once a minute while the plugin is healthy, and every 10 seconds when it is not.
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
- secrets
providers:
- kms:
apiVersion: v2
name: myKmsPluginFoo
endpoint: unix:///tmp/socketfile-foo.sock
timeout: 3s
- identity: {} # keep until all Secrets are re-encrypted, then remove
The page’s socket path is an example. Your plugin sets its own endpoint. The page says the providers list should end with the identity provider until the re-encryption steps are complete.
Write the configuration and restart kube-apiserver
Generate a local key
Skip this section if you use KMS. For a local key, generate 32 random bytes and base64 encode them. The page says you can use /dev/hwrng in place of /dev/urandom on devices that have a hardware random generator.
head -c 32 /dev/urandom | base64
Keep the key confidential while you generate it and afterwards. The page warns that a raw key in the config file “only moderately improves” your security posture, and recommends KMS for more secrecy.
Write the file and mount it
The page’s worked example uses aescbc. The page calls aescbc weak and not recommended, so use it only after you have weighed that note. The identity entry at the end allows reads of unencrypted data during migration.
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
- secrets
- configmaps
- pandas.awesome.bears.example
providers:
- aescbc:
keys:
- name: key1
# the base64 key from the generate step
secret:
- identity: {} # this fallback allows reading unencrypted secrets;
# for example, during initial migration
Then make the file available to kube-apiserver:
- Save the file to
/etc/kubernetes/enc/enc.yamlon the control plane node. - Add the flag and the mount to the static Pod manifest, as in the fragment below.
- Restart the API server. The page warns that the file holds keys that can decrypt etcd contents, so restrict its permissions to the user who runs kube-apiserver.
spec:
containers:
- command:
- kube-apiserver
- --encryption-provider-config=/etc/kubernetes/enc/enc.yaml
volumeMounts:
- name: enc
mountPath: /etc/kubernetes/enc
readOnly: true
volumes:
- name: enc
hostPath:
path: /etc/kubernetes/enc
type: DirectoryOrCreate
Roll the change out to every control plane host
A typical cluster has more than one control plane host, and each runs its own kube-apiserver. The page says to deploy the change to each API server in turn. It also says the encryption configuration must be identical on every control plane node, because a difference can leave an API server unable to decrypt data.
Copy the key to the other hosts with a secure mechanism. The page’s minimum is encryption in transit, such as SSH, and it prefers asymmetric encryption between hosts for more security. Then roll out host by host:
- Copy the key and the file to the next host over an encrypted channel.
- Update that host’s kube-apiserver manifest and restart the process.
- Confirm the host’s file matches the first host’s file before you move on.
Keep one record per host. An auditor who asks whether every control plane node enforces the same configuration needs that record.
Prove that new Secrets are encrypted
Create a test Secret, then read the raw value from etcd. The page uses a Secret named secret1 in the default namespace, and the commands below follow it.
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
ETCDCTL_API=3 etcdctl \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
get /registry/secrets/default/secret1 | hexdump -C
The etcd certificate paths are the page’s example. Substitute your own. Look for the provider prefix in the hexdump. The page’s output for aescbc contains this line, and it shows the key name in etcd:
00000020 31 0a 6b 38 73 3a 65 6e 63 3a 61 65 73 63 62 63 |1.k8s:enc:aescbc|
00000030 3a 76 31 3a 6b 65 79 31 3a c7 6c e7 d3 09 bc 06 |:v1:key1:.l.....|
The page says the k8s:enc:aescbc:v1: prefix means the aescbc provider encrypted the data, and that the key name in etcd must match the key name in the EncryptionConfiguration. The page documents this prefix only for aescbc. For any other provider, record the prefix from your own test output and keep that output with the config.
Last, confirm that the API still returns the value. The page expects mykey: bXlkYXRh in the output of this command:
kubectl get secret secret1 -n default -o yaml
Re-encrypt the Secrets that already exist
A new configuration encrypts what is written after the API server restarts. Secrets stored earlier stay in their old form until something writes them again. The page’s fix is to replace every Secret with its own data, which the API server then stores encrypted.
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
- Run the command as an administrator who can read and write all Secrets.
- If a conflicting write causes an error, retry. The page says the command is safe to run more than once.
- On a large cluster, split the work by namespace or script it, as the page suggests.
- Keep the command output and the date it ran. That is your record that existing Secrets were rewritten.
Remove the identity fallback
The identity provider lets the API server read Secrets that are still plain text, which helps during migration. Once every Secret is encrypted, remove it. The page says the change stops the API server from reading a plain-text Secret, even by accident.
The page warns that after this change the API server cannot retrieve resources marked as encrypted that are actually stored in clear. Check first. The page’s check is the etcdctl read shown earlier. It does not describe a bulk check, so record how you chose the Secrets you read.
- Confirm the re-encryption completed and that your sampled Secrets read as encrypted.
- Delete the
- identity: {}line from the providers list, and keep the key provider. - Restart each API server in turn.
Rotate keys and record each change
Rotation is a multi-step operation. The page’s steps keep every API server able to decrypt the stored data while the new key comes in. Automatic reload removes the restarts, as the FAQ above describes.
- Generate a new key and add it as the second key entry for the current provider on all control plane nodes.
- Restart all kube-apiserver processes, so each one can decrypt data written with the new key.
- Back up the new key securely. The page says that if all copies are lost, you would need to delete the resources encrypted under it.
- Make the new key the first entry in
keys, so it encrypts new writes. - Restart all kube-apiserver processes.
- Run the replace command from the re-encryption section to encrypt the existing Secrets with the new key.
- After the backup and re-encryption are done, remove the old key.
Two limits apply. The page says aesgcm must be rotated every 200,000 writes. For KMS, the page recommends rotating the key encryption key at least every 90 days, because you cannot control how many writes use a data encryption key.
Evidence to give an auditor
Each item below is evidence you can produce from the steps in this post. None of them shows that a control meets a particular standard. Check each one against the wording your auditor uses.
- The provider configuration. A copy of the EncryptionConfiguration with key values removed, plus the kube-apiserver manifest that sets the flag. It shows which resources are covered and which provider writes first. It does not show that the keys are protected, which the page leaves to you.
- A per-host match. One record for each control plane host showing that its file matches the others. The page says the configuration must be identical on every node.
- A dated write test. The etcdctl output for a test Secret, with its date and the provider prefix. It shows that one write was encrypted at that time, not that every object is.
- The re-encryption record. The output and date of the replace command. It shows that existing Secrets were rewritten after the change.
- Change timestamps. The automatic reload metric if you use automatic reload, or a record of each restart if you do not.
- The KMS key identity. For KMS, the key_id the plugin reports from its Status call, with the KMS provider’s own logs. The page says key_id is the public name of the remote key encryption key and may be logged.
- Approvals. The ticket or pull request for each configuration and key change. The page does not define approvals, so this comes from your process.
Keeping this evidence current
Key rotations and configuration changes are cluster changes, so each one needs a dated record alongside the rest of your compliance evidence. Keep the EncryptionConfiguration in that record without key values, because the file itself holds keys.
For exporting dated policy results and audit log events, read how to collect Kubernetes compliance evidence for auditors. For records that cover a workload’s exceptions, read how to document policy exceptions as audit evidence. The continuous compliance page is the starting point for the wider approach.
Sources checked
- Encrypting Confidential Data at Rest, fetched 2026-11-28. Provider table, configuration format, the etcdctl check, the replace command, rotation steps and the automatic reload flag.
- Using a KMS provider for data encryption, fetched 2026-11-28. KMS v1 and v2 status, the KMS v2 configuration, Status polling, key_id and the 90-day recommendation. The page states it describes Kubernetes 1.37.
- Good practices for Kubernetes Secrets, fetched 2026-11-28. Default storage and the base64 note.
Frequently asked questions
Does encrypting the etcd disk or the control plane host cover Secrets?
Not by itself. The Kubernetes task page says at-rest encryption for API data is additional to any system-level encryption for the etcd cluster or for the filesystems on hosts that run kube-apiserver. Keep the disk encryption evidence too. The auditor also needs proof that the API server writes Secrets encrypted with a key from your EncryptionConfiguration, which the disk setting does not show.
What happens if the encryption key is lost?
Resources you cannot read become unavailable. The Kubernetes page says that if a resource cannot be read because the keys changed, and you cannot restore a working configuration, your only recourse is to delete that entry from etcd directly. Reads fail until the entry is deleted or a valid key is provided. Keep a secure backup of every key you use, and record where each copy is held.
Does this encrypt Secrets that are mounted into pods as files?
No. The page limits its scope to resource data stored through the Kubernetes API, such as the key-value data in a Secret object. For data in filesystems mounted into containers, it points to a storage integration that provides encrypted volumes, or to encrypting the data inside your application. Mounted volumes need their own evidence.
Do I have to restart kube-apiserver to rotate an encryption key?
Not if you turn on automatic reload with the --encryption-provider-config-automatic-reload=true flag. The page says the API server then polls the config file every minute for changes. The metric apiserver_encryption_config_controller_automatic_reload_last_timestamp_seconds shows when a new config took effect. Without automatic reload, the page's rotation steps restart every kube-apiserver process.