Skip to content

Commit 332a501

Browse files
authored
Update csi-secrets-store-identity-access.md
1 parent 6fef19d commit 332a501

File tree

1 file changed

+2
-193
lines changed

1 file changed

+2
-193
lines changed

articles/aks/csi-secrets-store-identity-access.md

Lines changed: 2 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: nickomang
55
ms.author: nickoman
66
ms.service: azure-kubernetes-service
77
ms.topic: article
8-
ms.date: 09/27/2022
8+
ms.date: 01/31/2023
99
ms.custom: devx-track-azurecli
1010
---
1111

@@ -152,100 +152,7 @@ Azure AD workload identity (preview) is supported on both Windows and Linux clus
152152
EOF
153153
```
154154
155-
## Use pod-managed identities
156-
157-
Azure Active Directory (Azure AD) pod-managed identities (preview) use AKS primitives to associate managed identities for Azure resources and identities in Azure AD with pods. You can use these identities to grant access to the Azure Key Vault Secrets Provider for Secrets Store CSI driver.
158-
159-
### Prerequisites
160-
161-
- Ensure that the [Azure AD pod identity add-on][aad-pod-identity] has been enabled on your cluster.
162-
- You must be using a Linux-based cluster.
163-
164-
### Use an Azure AD pod-managed identity
165-
166-
1. Follow the instructions in [Use Azure Active Directory pod-managed identities in Azure Kubernetes Service (Preview)][aad-pod-identity-create] to create a cluster identity, assign it permissions, and create a pod identity. Take note of the newly created identity's `clientId` and `name`.
167-
168-
1. Assign permissions to the new identity to enable it to read your key vault and view its contents by running the following commands:
169-
170-
```azurecli-interactive
171-
# set policy to access keys in your key vault
172-
az keyvault set-policy -n <keyvault-name> --key-permissions get --spn <pod-identity-client-id>
173-
# set policy to access secrets in your key vault
174-
az keyvault set-policy -n <keyvault-name> --secret-permissions get --spn <pod-identity-client-id>
175-
# set policy to access certs in your key vault
176-
az keyvault set-policy -n <keyvault-name> --certificate-permissions get --spn <pod-identity-client-id>
177-
```
178-
179-
1. Create a `SecretProviderClass` by using the following YAML, using your own values for `aadpodidbinding`, `tenantId`, and the objects to retrieve from your key vault:
180-
181-
```yml
182-
# This is a SecretProviderClass example using aad-pod-identity to access the key vault
183-
apiVersion: secrets-store.csi.x-k8s.io/v1
184-
kind: SecretProviderClass
185-
metadata:
186-
name: azure-kvname-podid
187-
spec:
188-
provider: azure
189-
parameters:
190-
usePodIdentity: "true" # Set to true for using aad-pod-identity to access your key vault
191-
keyvaultName: <key-vault-name> # Set to the name of your key vault
192-
cloudName: "" # [OPTIONAL for Azure] if not provided, the Azure environment defaults to AzurePublicCloud
193-
objects: |
194-
array:
195-
- |
196-
objectName: secret1
197-
objectType: secret # object types: secret, key, or cert
198-
objectVersion: "" # [OPTIONAL] object versions, default to latest if empty
199-
- |
200-
objectName: key1
201-
objectType: key
202-
objectVersion: ""
203-
tenantId: <tenant-Id> # The tenant ID of the key vault
204-
```
205-
206-
1. Apply the `SecretProviderClass` to your cluster:
207-
208-
```bash
209-
kubectl apply -f secretproviderclass.yaml
210-
```
211-
212-
1. Create a pod by using the following YAML, using the name of your identity:
213-
214-
```yml
215-
# This is a sample pod definition for using SecretProviderClass and aad-pod-identity to access the key vault
216-
kind: Pod
217-
apiVersion: v1
218-
metadata:
219-
name: busybox-secrets-store-inline-podid
220-
labels:
221-
aadpodidbinding: <name> # Set the label value to the name of your pod identity
222-
spec:
223-
containers:
224-
- name: busybox
225-
image: k8s.gcr.io/e2e-test-images/busybox:1.29-1
226-
command:
227-
- "/bin/sleep"
228-
- "10000"
229-
volumeMounts:
230-
- name: secrets-store01-inline
231-
mountPath: "/mnt/secrets-store"
232-
readOnly: true
233-
volumes:
234-
- name: secrets-store01-inline
235-
csi:
236-
driver: secrets-store.csi.k8s.io
237-
readOnly: true
238-
volumeAttributes:
239-
secretProviderClass: "azure-kvname-podid"
240-
```
241-
242-
1. Apply the pod to your cluster:
243-
244-
```bash
245-
kubectl apply -f pod.yaml
246-
```
247-
248-
## Use a user-assigned managed identity
155+
## Use the CSI Secret Store addon user-assigned managed identity
249156
250157
1. To access your key vault, you can use the user-assigned managed identity that you created when you [enabled a managed identity on your AKS cluster][use-managed-identity]:
251158
@@ -340,104 +247,6 @@ Azure Active Directory (Azure AD) pod-managed identities (preview) use AKS primi
340247
```bash
341248
kubectl apply -f pod.yaml
342249
```
343-
344-
## Use a system-assigned managed identity
345-
346-
### Prerequisites
347-
348-
>[!IMPORTANT]
349-
> Before you begin this step, [enable system-assigned managed identity][enable-system-assigned-identity] on your AKS cluster's VMs or scale sets.
350-
>
351-
352-
### Usage
353-
354-
1. Verify that your Virtual Machine Scale Set or Availability Set nodes have their own system-assigned identity:
355-
356-
```azurecli-interactive
357-
az vmss identity show -g <resource group> -n <vmss scalset name> -o yaml
358-
az vm identity show -g <resource group> -n <vm name> -o yaml
359-
```
360-
361-
>[!NOTE]
362-
> The output should contain `type: SystemAssigned`. Make a note of the `principalId`.
363-
>
364-
> IMDS is looking for a System Assigned Identity on VMSS first, then it will look for a User Assigned Identity and pull that if there is only 1. If there are multiple User Assigned Identities IMDS will throw an error as it does not know which identity to pull.
365-
>
366-
367-
1. To grant your identity permissions that enable it to read your key vault and view its contents, run the following commands:
368-
369-
```azurecli-interactive
370-
# set policy to access keys in your key vault
371-
az keyvault set-policy -n <keyvault-name> --key-permissions get --spn <identity-principal-id>
372-
# set policy to access secrets in your key vault
373-
az keyvault set-policy -n <keyvault-name> --secret-permissions get --spn <identity-principal-id>
374-
# set policy to access certs in your key vault
375-
az keyvault set-policy -n <keyvault-name> --certificate-permissions get --spn <identity-principal-id>
376-
```
377-
378-
1. Create a `SecretProviderClass` by using the following YAML, using your own values for `keyvaultName`, `tenantId`, and the objects to retrieve from your key vault:
379-
380-
```yml
381-
# This is a SecretProviderClass example using system-assigned identity to access your key vault
382-
apiVersion: secrets-store.csi.x-k8s.io/v1
383-
kind: SecretProviderClass
384-
metadata:
385-
name: azure-kvname-system-msi
386-
spec:
387-
provider: azure
388-
parameters:
389-
usePodIdentity: "false"
390-
useVMManagedIdentity: "true" # Set to true for using managed identity
391-
userAssignedIdentityID: "" # If empty, then defaults to use the system assigned identity on the VM
392-
keyvaultName: <key-vault-name>
393-
cloudName: "" # [OPTIONAL for Azure] if not provided, the Azure environment defaults to AzurePublicCloud
394-
objects: |
395-
array:
396-
- |
397-
objectName: secret1
398-
objectType: secret # object types: secret, key, or cert
399-
objectVersion: "" # [OPTIONAL] object versions, default to latest if empty
400-
- |
401-
objectName: key1
402-
objectType: key
403-
objectVersion: ""
404-
tenantId: <tenant-id> # The tenant ID of the key vault
405-
```
406-
407-
1. Apply the `SecretProviderClass` to your cluster:
408-
409-
```bash
410-
kubectl apply -f secretproviderclass.yaml
411-
```
412-
413-
1. Create a pod by using the following YAML:
414-
415-
```yml
416-
# This is a sample pod definition for using SecretProviderClass and system-assigned identity to access your key vault
417-
kind: Pod
418-
apiVersion: v1
419-
metadata:
420-
name: busybox-secrets-store-inline-system-msi
421-
spec:
422-
containers:
423-
- name: busybox
424-
image: k8s.gcr.io/e2e-test-images/busybox:1.29-1
425-
command:
426-
- "/bin/sleep"
427-
- "10000"
428-
volumeMounts:
429-
- name: secrets-store01-inline
430-
mountPath: "/mnt/secrets-store"
431-
readOnly: true
432-
volumes:
433-
- name: secrets-store01-inline
434-
csi:
435-
driver: secrets-store.csi.k8s.io
436-
readOnly: true
437-
volumeAttributes:
438-
secretProviderClass: "azure-kvname-system-msi"
439-
```
440-
441250
## Next steps
442251
443252
To validate that the secrets are mounted at the volume path that's specified in your pod's YAML, see [Use the Azure Key Vault Provider for Secrets Store CSI Driver in an AKS cluster][validate-secrets].

0 commit comments

Comments
 (0)