I'm facing an issue with mounting an Azure File Share in a Kubernetes cluster using User-Assigned Managed Identity (UAMI). Although I already have the Azure File CSI driver installed and it is running correctly, I keep encountering the error:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 45s default-scheduler Successfully assigned default/mypod to aks-agentpool-xxxx
Warning FailedMount 14s (x7 over 46s) kubelet MountVolume.SetUp failed for volume "azure" : rpc error: code = InvalidArgument desc = failed to get account name from csi-xxx
Here's what I've tried so far:
Verified UAMI Permissions:UAMI has “Storage Account Contributor" role on the Azure storage account.
Checked AzureIdentity and AzureIdentityBinding in Kubernetes: Ensured that these resources are correctly configured. The AzureIdentity has the correct
clientID
andresourceID
, and theAzureIdentityBinding
’s selector matches theaadpodidbinding
label in my pod.Pod Configuration: My pod has the correct aadpodidbinding label. The pod.yaml is configured to use SMB protocol
CSI Driver Logs: I am unable to retrieve logs from the Azure File CSI driver pods. Running
kubectl logs -l app=csi-azurefile -n kube-system
returns "No resources found in kube-system namespace,"
even though the pods are present and running.Pod Events: Reviewed events for the pod but didn't find specific clues pointing to the root cause of the issue.
I think the issue might be related to UAMI authentication or Azure File CSI driver configuration but am unable to pinpoint the exact cause. The fact that I can't access the CSI driver logs is also puzzling.
Any insights or suggestions on how to resolve this or further diagnose the issue would be greatly appreciated.
To mount an Azure File Share on a Kubernetes cluster using a User-Assigned Managed Identity, you should start by creating an AKS cluster with user assigned managed identity.
This can be achieved using the following Azure CLI command-
You can verify the same using az identity show --ids
or from portal
Next comes the Azure file share mounting part.
Go to your cluster, determine your cluster's resource group name by using the
az aks show
command with the--query nodeResourceGroup
parameter.Output:
Next, create a storage account :
Following this, declare the storage account connection string as an environment variable for future use in file share creation:
Proceed to create the file share, replacing
shareName
with your chosen name:Output
Export the storage account key:
Use these credentials to create a Kubernetes secret. you will need these values when creating the Kubernetes volume.
kubectl create secret
output
Mount file share as a persistent volume, the default value for
fileMode
anddirMode
is 0777.Next, setup the persistent volume and claim by applying the configuration accordingly.
Confirm the creation and binding of the PVC:
output
Update your container specifications to integrate the PVC.
Reference Document: Ms Doc Ms Doc Mount File share guide Similar thread