You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Use KMS etcd encryption in Azure Kubernetes Service (AKS) (Preview)
2
+
title: Use KMS etcd encryption in Azure Kubernetes Service (AKS)
3
3
description: Learn how to use kms etcd encryption with Azure Kubernetes Service (AKS)
4
4
services: container-service
5
5
ms.topic: article
6
-
ms.date: 06/06/2022
6
+
ms.date: 07/26/2022
7
7
8
8
---
9
9
10
-
# Add KMS etcd encryption to an Azure Kubernetes Service (AKS) cluster (Preview)
10
+
# Add KMS etcd encryption to an Azure Kubernetes Service (AKS) cluster
11
11
12
12
This article shows you how to enable encryption at rest for your Kubernetes data in etcd using Azure Key Vault with Key Management Service (KMS) plugin. The KMS plugin allows you to:
13
13
14
14
* Use a key in Key Vault for etcd encryption
15
15
* Bring your own keys
16
16
* Provide encryption at rest for secrets stored in etcd
17
+
* Rotate the keys in Key Vault
17
18
18
19
For more information on using the KMS plugin, see [Encrypting Secret Data at Rest](https://kubernetes.io/docs/tasks/administer-cluster/kms-provider/).
19
20
20
-
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
21
-
22
21
## Before you begin
23
22
24
23
* An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free).
You also need the *aks-preview* Azure CLI extension version 0.5.58 or later. Install the *aks-preview* Azure CLI extension by using the [az extension add][az-extension-add] command. Or install any available updates by using the [az extension update][az-extension-update] command.
30
-
31
-
```azurecli-interactive
32
-
# Install the aks-preview extension
33
-
az extension add --name aks-preview
34
-
# Update the extension to make sure you have the latest version installed
35
-
az extension update --name aks-preview
36
-
```
37
-
38
-
### Register the `AzureKeyVaultKmsPreview` preview feature
39
-
40
-
To use the feature, you must also enable the `AzureKeyVaultKmsPreview` feature flag on your subscription.
41
-
42
-
Register the `AzureKeyVaultKmsPreview` feature flag by using the [az feature register][az-feature-register] command, as shown in the following example:
24
+
* Azure CLI version 2.39.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
43
25
44
-
```azurecli-interactive
45
-
az feature register --namespace "Microsoft.ContainerService" --name "AzureKeyVaultKmsPreview"
46
-
```
47
-
48
-
It takes a few minutes for the status to show *Registered*. Verify the registration status by using the [az feature list][az-feature-list] command:
49
-
50
-
```azurecli-interactive
51
-
az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/AzureKeyVaultKmsPreview')].{Name:name,State:properties.state}"
52
-
```
53
-
54
-
When ready, refresh the registration of the *Microsoft.ContainerService* resource provider by using the [az provider register][az-provider-register] command:
55
-
56
-
```azurecli-interactive
57
-
az provider register --namespace Microsoft.ContainerService
58
-
```
26
+
> [!WARNING]
27
+
> KMS only supports Konnectivity. You could use `kubectl get po -n kube-system` to check whether there is 'konnectivity-agent-xxx' pod running.
59
28
60
29
## Limitations
61
30
62
31
The following limitations apply when you integrate KMS etcd encryption with AKS:
63
32
64
-
* Disabling of the KMS etcd encryption feature.
65
-
* Changing of key ID, including key name and key version.
66
33
* Deletion of the key, Key Vault, or the associated identity.
67
34
* KMS etcd encryption doesn't work with System-Assigned Managed Identity. The keyvault access-policy is required to be set before the feature is enabled. In addition, System-Assigned Managed Identity isn't available until cluster creation, thus there's a cycle dependency.
68
35
* Using more than 2000 secrets in a cluster.
69
36
* Bring your own (BYO) Azure Key Vault from another tenant.
37
+
* Change associated Azure Key Vault model (public, private) if KMS is enabled. For [changing associated key vault mode][changing-associated-key-vault-mode], you need to disable and enable KMS again.
38
+
* Stop/satrt cluster which is enabled KMS with private key vault.
39
+
40
+
KMS supports [public key vault][Enable-KMS-with-public-key-vault] and [private key vault][Enable-KMS-with-private-key-vault] now.
70
41
71
-
## Create a KeyVault and key
42
+
## Enable KMS with public key vault
43
+
44
+
### Create a key vault and key
72
45
73
46
> [!WARNING]
74
-
> Deleting the key or the Azure Key Vault is not supported and will cause your cluster to become unstable.
47
+
> Deleting the key or the Azure Key Vault is not supported and will cause the secrets to be unrecoverable in the cluster.
75
48
>
76
49
> If you need to recover your Key Vault or key, see the [Azure Key Vault recovery management with soft delete and purge protection](../key-vault/general/key-vault-recovery.md?tabs=azure-cli) documentation.
77
50
@@ -96,7 +69,7 @@ echo $KEY_ID
96
69
97
70
The above example stores the Key ID in *KEY_ID*.
98
71
99
-
## Create a user-assigned managed identity
72
+
###Create a user-assigned managed identity
100
73
101
74
Use `az identity create` to create a User-assigned managed identity.
102
75
@@ -122,28 +95,28 @@ echo $IDENTITY_RESOURCE_ID
122
95
123
96
The above example stores the value of the Identity Resource ID in *IDENTITY_RESOURCE_ID*.
124
97
125
-
## Assign permissions (decrypt and encrypt) to access key vault
98
+
###Assign permissions (decrypt and encrypt) to access key vault
126
99
127
100
Use `az keyvault set-policy` to create an Azure KeyVault policy.
128
101
129
102
```azurecli-interactive
130
103
az keyvault set-policy -n MyKeyVault --key-permissions decrypt encrypt --object-id $IDENTITY_OBJECT_ID
131
104
```
132
105
133
-
## Create an AKS cluster with KMS etcd encryption enabled
106
+
###Create an AKS cluster with KMS etcd encryption enabled
134
107
135
-
Create an AKS cluster using the [az aks create][az-aks-create] command with the `--enable-azure-keyvault-kms` and `--azure-keyvault-kms-key-id` parameters to enable KMS etcd encryption.
108
+
Create an AKS cluster using the [az aks create][az-aks-create] command with the `--enable-azure-keyvault-kms`, `--azure-keyvault-kms-key-vault-network-access` and `--azure-keyvault-kms-key-id` parameters to enable KMS etcd encryption.
136
109
137
110
```azurecli-interactive
138
-
az aks create --name myAKSCluster --resource-group MyResourceGroup --assign-identity $IDENTITY_RESOURCE_ID --enable-azure-keyvault-kms --azure-keyvault-kms-key-id $KEY_ID
111
+
az aks create --name myAKSCluster --resource-group MyResourceGroup --assign-identity $IDENTITY_RESOURCE_ID --enable-azure-keyvault-kms --azure-keyvault-kms-key-vault-network-access "Public" --azure-keyvault-kms-key-id $KEY_ID
139
112
```
140
113
141
-
## Update an exiting AKS cluster to enable KMS etcd encryption
114
+
###Update an exiting AKS cluster to enable KMS etcd encryption
142
115
143
-
Use [az aks update][az-aks-update] with the `--enable-azure-keyvault-kms` and `--azure-keyvault-kms-key-id` parameters to enable KMS etcd encryption on an existing cluster.
116
+
Use [az aks update][az-aks-update] with the `--enable-azure-keyvault-kms`, `--azure-keyvault-kms-key-vault-network-access` and `--azure-keyvault-kms-key-id` parameters to enable KMS etcd encryption on an existing cluster.
144
117
145
118
```azurecli-interactive
146
-
az aks update --name myAKSCluster --resource-group MyResourceGroup --enable-azure-keyvault-kms --azure-keyvault-kms-key-id $KEY_ID
119
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --enable-azure-keyvault-kms --azure-keyvault-kms-key-vault-network-access "Public" --azure-keyvault-kms-key-id $KEY_ID
147
120
```
148
121
149
122
Use below command to update all secrets. Otherwise, the old secrets aren't encrypted.
@@ -152,6 +125,182 @@ Use below command to update all secrets. Otherwise, the old secrets aren't encry
> For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
130
+
131
+
### Rotate the existing keys
132
+
After changing the key ID (including key name and key version), you could use [az aks update][az-aks-update] with the `--enable-azure-keyvault-kms`, `--azure-keyvault-kms-key-vault-network-access` and `--azure-keyvault-kms-key-id` parameters to rotate the exitsing keys of KMS.
133
+
134
+
> [!WARNING]
135
+
> Remember to update all secrets after key rotation. Otheriwse, the secrets will be unaccessable if the old keys are not existing or working.
136
+
137
+
```azurecli-interactive
138
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --enable-azure-keyvault-kms --azure-keyvault-kms-key-vault-network-access "Public" --azure-keyvault-kms-key-id $NEW_KEY_ID
139
+
```
140
+
141
+
Use below command to update all secrets. Otherwise, the old secrets are still encrypted with the previous key.
> For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
149
+
150
+
## Enable KMS with private key vault
151
+
152
+
If you enable KMS with private key vault, AKS will create a private endpoint and private link in the node resource group automatically. The key vault will be added a private endpoint connection with the AKS cluster.
153
+
154
+
### Create a private key vault and key
155
+
156
+
> [!WARNING]
157
+
> Deleting the key or the Azure Key Vault is not supported and will cause the secrets to be unrecoverable in the cluster.
158
+
>
159
+
> If you need to recover your Key Vault or key, see the [Azure Key Vault recovery management with soft delete and purge protection](../key-vault/general/key-vault-recovery.md?tabs=azure-cli) documentation.
160
+
161
+
162
+
Use `az keyvault create` to create a priate KeyVault.
163
+
164
+
```azurecli
165
+
az keyvault create --name MyKeyVault --resource-group MyResourceGroup --public-network-access Disabled
166
+
```
167
+
168
+
Without private endpoint, it's not supported to create or update keys in private key vault. To manage private key vault, you could refer to [Integrate Key Vault with Azure Private Link](../key-vault/general/private-link-service.md).
169
+
170
+
### Create a user-assigned managed identity
171
+
172
+
Use `az identity create` to create a User-assigned managed identity.
173
+
174
+
```azurecli
175
+
az identity create --name MyIdentity --resource-group MyResourceGroup
The above example stores the value of the Identity Resource ID in *IDENTITY_RESOURCE_ID*.
195
+
196
+
### Assign permissions (decrypt and encrypt) to access key vault
197
+
198
+
Use `az keyvault set-policy` to create an Azure KeyVault policy.
199
+
200
+
```azurecli-interactive
201
+
az keyvault set-policy -n MyKeyVault --key-permissions decrypt encrypt --object-id $IDENTITY_OBJECT_ID
202
+
```
203
+
204
+
For private key vault, the AKS needs *Key Vault Contributor* role to create private link between private key vault and cluster.
205
+
206
+
```azurecli-interactive
207
+
az role assignment create --role "Key Vault Contributor" --assignee-object-id $IDENTITY_OBJECT_ID --assignee-principal-type "ServicePrincipal" --scope $KEYVAULT_RESOURCE_ID
208
+
```
209
+
210
+
### Create an AKS cluster with private key vault and enable KMS etcd encryption
211
+
212
+
Create an AKS cluster using the [az aks create][az-aks-create] command with the `--enable-azure-keyvault-kms`, `--azure-keyvault-kms-key-id`, `--azure-keyvault-kms-key-vault-network-access` and `--azure-keyvault-kms-key-vault-resource-id` parameters to enable KMS etcd encryption with private key vault.
213
+
214
+
```azurecli-interactive
215
+
az aks create --name myAKSCluster --resource-group MyResourceGroup --assign-identity $IDENTITY_RESOURCE_ID --enable-azure-keyvault-kms --azure-keyvault-kms-key-id $KEY_ID --azure-keyvault-kms-key-vault-network-access "Private" --azure-keyvault-kms-key-vault-resource-id $KEYVAULT_RESOURCE_ID
216
+
```
217
+
218
+
### Update an exiting AKS cluster to enable KMS etcd encryption with private key vault
219
+
220
+
Use [az aks update][az-aks-update] with the `--enable-azure-keyvault-kms`, `--azure-keyvault-kms-key-id`, `--azure-keyvault-kms-key-vault-network-access` and `--azure-keyvault-kms-key-vault-resource-id` parameters to enable KMS etcd encryption on an existing cluster with private key vault.
221
+
222
+
```azurecli-interactive
223
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --enable-azure-keyvault-kms --azure-keyvault-kms-key-id $KEY_ID --azure-keyvault-kms-key-vault-network-access "Private" --azure-keyvault-kms-key-vault-resource-id $KEYVAULT_RESOURCE_ID
224
+
```
225
+
226
+
Use below command to update all secrets. Otherwise, the old secrets aren't encrypted.
> For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
234
+
235
+
### Rotate the existing keys
236
+
After changing the key ID (including key name and key version), you could use [az aks update][az-aks-update] with the `--enable-azure-keyvault-kms`, `--azure-keyvault-kms-key-id`, `--azure-keyvault-kms-key-vault-network-access` and `--azure-keyvault-kms-key-vault-resource-id` parameters to rotate the existing keys of KMS.
237
+
238
+
> [!WARNING]
239
+
> Remember to update all secrets after key rotation. Otherwise, the secrets will be unaccessable if the old keys are not existing or working.
240
+
241
+
```azurecli-interactive
242
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --enable-azure-keyvault-kms --azure-keyvault-kms-key-id $NewKEY_ID --azure-keyvault-kms-key-vault-network-access "Private" --azure-keyvault-kms-key-vault-resource-id $KEYVAULT_RESOURCE_ID
243
+
```
244
+
245
+
Use below command to update all secrets. Otherwise, the old secrets are still encrypted with the previous key.
> For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
253
+
254
+
## Update key vault mode
255
+
256
+
> [!NOTE]
257
+
> To change a different key vault with different mode (public, private), you could run `az aks update` directly. To change the mode of attached key vault, you need to diable KMS and re-enable it with new key vault ids.
258
+
259
+
Below are the steps about how to migrate the attached public key vault to private mode.
260
+
261
+
### Disable KMS on the cluster
262
+
263
+
Use below command to disable the KMS on existing cluster and release the key vault.
264
+
265
+
```azurecli-interactive
266
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --disable-azure-keyvault-kms
267
+
```
268
+
269
+
### Change key vault mode
270
+
271
+
Update the key vault from public to private.
272
+
273
+
```azurecli-interactive
274
+
az keyvault update --name MyKeyVault --resource-group MyResourceGroup --public-network-access Disabled
275
+
```
276
+
277
+
### Enable KMS on the cluster with updated key vault
278
+
279
+
Use below command to re-enable the KMS with updated private key vault.
280
+
281
+
```azurecli-interactive
282
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --enable-azure-keyvault-kms --azure-keyvault-kms-key-id $NewKEY_ID --azure-keyvault-kms-key-vault-network-access "Private" --azure-keyvault-kms-key-vault-resource-id $KEYVAULT_RESOURCE_ID
283
+
```
284
+
285
+
After configuring KMS, you could enable [diagnostic-settings for key vault to check the encryption logs](../key-vault/general/howto-logging.md).
286
+
287
+
## Disable KMS
288
+
289
+
Use below command to disable KMS on existing cluster.
290
+
291
+
```azurecli-interactive
292
+
az aks update --name myAKSCluster --resource-group MyResourceGroup --disable-azure-keyvault-kms
293
+
```
294
+
295
+
Use below command to update all secrets. Otherwise, the old secrets are still encrypted with the previous key.
0 commit comments