|
2 | 2 | - supported from v1.24.0 (from AKS 1.29 with `tokenRequests` field support in `CSIDriver`) |
3 | 3 |
|
4 | 4 | ### Note |
5 | | - - This feature is not supported for NFS mount since NFS mount does not need credentials. |
6 | | - - This feature would retrieve storage account key using federated identity credentials by default. |
7 | | - - This feature supports mounting with workload identity token only (**Preview**) by configuring the following: |
8 | | - > limitation: the workload identity token would expire after 24 hours, make sure the blobfuse volume would be remounted by your application before it expires |
9 | | - - set `mountWithWorkloadIdentityToken: "true"` in parameters of storage class or persistent volume |
10 | | - - set `Storage Blob Data Contributor` role on the identity |
| 5 | + - This feature is not supported for NFS mount since NFS mount does not need credentials during mount. |
| 6 | + - This feature would retrieve storage account key using federated identity credentials by default, you could mount with workload identity token only (**Preview**) by configuring as following: |
| 7 | + > mounting with workload identity token only is supported from v1.27.0 |
| 8 | + - set `mountWithWorkloadIdentityToken: "true"` in `parameters` of storage class or persistent volume |
| 9 | + - grant `Storage Blob Data Contributor` role instead of `Storage Account Contributor` role to the managed identity |
11 | 10 |
|
12 | 11 | ## Prerequisites |
13 | 12 | ### 1. Create a cluster with oidc-issuer enabled and get the credential |
14 | 13 |
|
15 | | -Following the [documentation](https://learn.microsoft.com/en-us/azure/aks/use-oidc-issuer#create-an-aks-cluster-with-oidc-issuer) to create an AKS cluster with the `--enable-oidc-issuer` parameter and get the AKS credentials. And export following environment variables: |
16 | | -``` |
| 14 | +Refer to the [documentation](https://learn.microsoft.com/en-us/azure/aks/use-oidc-issuer#create-an-aks-cluster-with-oidc-issuer) for instructions on creating a new AKS cluster with the `--enable-oidc-issuer` parameter and get the AKS credentials. And export following environment variables: |
| 15 | +```console |
17 | 16 | export RESOURCE_GROUP=<your resource group name> |
18 | 17 | export CLUSTER_NAME=<your cluster name> |
19 | 18 | export REGION=<your region> |
20 | 19 | ``` |
21 | 20 |
|
22 | 21 | ### 2. Bring your own storage account and storage container |
23 | | -Following the [documentation](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-cli) to create a new storage account and container or use your own. And export following environment variables: |
24 | | -``` |
| 22 | +Refer to the [documentation](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-cli) for instructions on creating a new storage account and container, or alternatively, utilize your existing storage account and container. And export following environment variables: |
| 23 | +```console |
25 | 24 | export STORAGE_RESOURCE_GROUP=<your storage account resource group> |
26 | 25 | export ACCOUNT=<your storage account name> |
27 | 26 | export CONTAINER=<your storage container name> |
28 | 27 | ``` |
29 | 28 |
|
30 | | -### 3. Create managed identity and role assignment |
31 | | -``` |
| 29 | +### 3. Create or bring your own managed identity and role assignment |
| 30 | +> you could leverage the default user assigned managed identity bound to the AKS agent node pool(with naming rule [`AKS Cluster Name-agentpool`](https://docs.microsoft.com/en-us/azure/aks/use-managed-identity#summary-of-managed-identities)) in node resource group |
| 31 | +```console |
32 | 32 | export UAMI=<your managed identity name> |
33 | 33 | az identity create --name $UAMI --resource-group $RESOURCE_GROUP |
34 | 34 |
|
35 | 35 | export USER_ASSIGNED_CLIENT_ID="$(az identity show -g $RESOURCE_GROUP --name $UAMI --query 'clientId' -o tsv)" |
36 | 36 | export IDENTITY_TENANT=$(az aks show --name $CLUSTER_NAME --resource-group $RESOURCE_GROUP --query identity.tenantId -o tsv) |
37 | 37 | export ACCOUNT_SCOPE=$(az storage account show --name $ACCOUNT --query id -o tsv) |
| 38 | +``` |
| 39 | + - grant `Storage Account Contributor` role to the managed identity to retrieve account key (default) |
| 40 | +```console |
| 41 | +az role assignment create --role "Storage Account Contributor" --assignee $USER_ASSIGNED_CLIENT_ID --scope $ACCOUNT_SCOPE |
| 42 | +``` |
38 | 43 |
|
39 | | -# please retry if you meet `Cannot find user or service principal in graph database` error, it may take a while for the identity to propagate |
| 44 | + - grant the `Storage Blob Data Contributor` role to the managed identity for mounting using a workload identity token exclusively, without relying on account key authentication. |
| 45 | +```console |
40 | 46 | az role assignment create --role "Storage Account Contributor" --assignee $USER_ASSIGNED_CLIENT_ID --scope $ACCOUNT_SCOPE |
41 | 47 | ``` |
42 | 48 |
|
@@ -66,7 +72,7 @@ az identity federated-credential create --name $FEDERATED_IDENTITY_NAME \ |
66 | 72 | --subject system:serviceaccount:${SERVICE_ACCOUNT_NAMESPACE}:${SERVICE_ACCOUNT_NAME} |
67 | 73 | ``` |
68 | 74 | ## option#1: dynamic provisioning with storage class |
69 | | -``` |
| 75 | +```yaml |
70 | 76 | cat <<EOF | kubectl apply -f - |
71 | 77 | apiVersion: storage.k8s.io/v1 |
72 | 78 | kind: StorageClass |
|
0 commit comments