Protect Secrets at rest with Key Management Service (KMS) envelope encryption in ACK Pro clusters.
Prerequisites
Ensure that you have:
A KMS key in the same region as your ACK Pro cluster. Supported types: default, software-protected, and hardware-protected. See Getting started with keys and Billing.
Authorization to enable Secret encryption:
Alibaba Cloud account: authorized to assume AliyunCSManagedSecurityRole. The ACK console prompts for authorization when you enable Secret encryption, or go to the Cloud Resource Access Authorization page directly.
RAM user or RAM role: must have both:
Administrator or O&M engineer RBAC permissions on the ACK Pro cluster. See Grant RBAC permissions to RAM users or RAM roles.
Granted the AliyunKMSCryptoAdminAccess system permission. See Grant permissions to a RAM user or RAM role.
Limitations
Secret encryption is supported only on ACK Pro clusters and ACK Serverless Pro clusters.
After enabling Secret encryption, do not disable or delete the key via the KMS API or console. If the key becomes unavailable, the API server cannot retrieve Secrets or service account objects, causing service interruptions.
To disable Secret encryption, turn off Secret Encryption in the cluster's Basic Information tab.
How it works
ACK uses the Kubernetes KMS provider with envelope encryption to protect Secrets in etcd. The Secret is encrypted with a data encryption key (DEK), and the DEK is encrypted with a key encryption key (KEK) in KMS. The plaintext DEK is never stored alongside the data it protects.
Encryption:
When you store a Secret, the API server generates a random DEK and encrypts the Secret with it.
The API server sends the DEK to KMS, which encrypts it with your KMS key (the KEK) and returns the encrypted DEK.
The API server stores both the encrypted Secret and the encrypted DEK in etcd.
Decryption:
The API server calls the KMS
Decryptoperation to decrypt the DEK.The API server uses the plaintext DEK to decrypt the Secret and returns it to the caller.
For more information, see the KMS encryption provider and Use envelope encryption.
KMS v2
Starting with Kubernetes 1.31, ACK Pro clusters and use the community KMS v2 interface for encryption at rest. KMS v2 supports more Secret instances in a cluster and provides better encryption and decryption performance. For more information about the KMS v2 encryption and decryption flow, see KMS v2.
To upgrade from the KMS v1 interface to the KMS v2 interface, see How to upgrade to KMS v2 for Secret encryption at rest?
The Kubernetes community marked KMS v1 as deprecated in version 1.27 and disabled the v1 interface by default in version 1.29. To ensure compatibility, ACK Pro clusters and still enable the v1 interface by setting the KMS v1 feature gate.
Enable encryption at rest for Secrets
New ACK Pro cluster
Log on to the ACK console and click Clusters in the left-side navigation pane.
On the Clusters page, click Cluster Templates. On the Select Cluster Template page, find Professional Managed Kubernetes Cluster and click Create.
On the Managed Kubernetes tab, click Show Advanced Options. In the Secret Encryption section, select Select Key and choose a key. Configure other parameters and click Create Cluster. See Create an ACK Pro cluster.

Do not disable or delete the KMS key after enabling Secret encryption. If the key becomes unavailable, the API server cannot retrieve Secrets or service account objects, causing service interruptions.
Verify: Log on to the ActionTrail console. Click Event Detail Query in the navigation pane. If encryption and decryption operations from the aliyuncsmanagedsecurityrole role appear, Secret encryption is active.
Existing ACK Pro cluster
Log on to the ACK console and click Clusters in the left-side navigation pane.
On the Clusters page, click the target cluster name. Click the Basic Information tab. In the Security and Audit section, turn on Secret Encryption. If prompted for authorization, click Go to RAM console, then click Confirm Authorization Policy.
The RAM user or role must have the administrator or O&M engineer RBAC role on the cluster. To assign AliyunCSManagedSecurityRole, log on with an Alibaba Cloud account or a RAM identity with RAM management permissions.
In the Secret Encryption dialog box, select a key and click OK. If no key is available, click create keys in the KMS console. See Create a CMK. When the cluster status changes from Updating to Running, Secret encryption is enabled.
Do not disable or delete the KMS key after enabling Secret encryption. If the key becomes unavailable, the API server cannot retrieve Secrets or service account objects, causing service interruptions.
To disable:In the Security and Audit section of the cluster details page, turn off Secret Encryption.
Rotate the encryption key
KMS automatic key rotation encrypts new Secrets with the rotated key. Existing Secrets remain encrypted with the original key until you explicitly re-encrypt them.
Manual re-encryption: After rotation completes, re-encrypt all existing Secrets with the new key:
kubectl get secrets --all-namespaces -o json | kubectl annotate --overwrite -f - encryption-key-rotation-time="$(date -u +'%Y-%m-%dT%H:%M:%S%z')"See Configure key rotation for automatic key rotation setup.
FAQ
How to upgrade to KMS v2 for Secret encryption at rest?
To use KMS v2 for Secret encryption at rest, make sure your ACK Pro cluster or is version 1.31 or later.
If you have not enabled Secret encryption at rest on your cluster, see Enable encryption at rest for Secrets to enable it. After encryption is enabled, Secrets in the cluster are automatically encrypted using KMS v2 APIs when they are written to disk and decrypted when they are read.
If you have already enabled Secret encryption at rest on your cluster, you can rotate the encryption key during off-peak hours using one of the following methods.
Method 1: Run the
kubectl get secrets --all-namespaces -o json | kubectl replace -f -command. This command re-encrypts all existing Secrets using the KMS v2 API.Method 2: Log on to ACK console. On the Cluster Information page, go to the Basic Information tab, find Secret Encryption, and turn it off. This process triggers a key rotation for all Secrets on disk. After a while, see Enable encryption at rest for Secrets to re-enable encryption for the cluster. After encryption is re-enabled, all Secrets in the cluster are re-encrypted at rest using the KMS v2 API.
Does kubectl return ciphertext after Secret encryption is enabled?
No. Secrets are stored as ciphertext in etcd. When queried through kubectl, the API server decrypts them before returning results, so kubectl always shows plaintext.
How do I prevent RAM users or RAM roles from enabling or disabling Secret encryption for existing ACK Serverless Pro clusters?
Attach a deny policy for the cs:UpdateKMSEncryption action to the RAM users or roles. See Create a custom RAM policy.
{
"Action": [
"cs:UpdateKMSEncryption"
],
"Effect": "Deny",
"Resource": [
"*"
]
}