How to access fileshare from POD using workload identity

Sriramulu, Latha 0 Reputation points
2024-04-01T13:03:42.41+00:00

Trying to access azurefile share storage from POD using workload identity

Enabled workload identity, created managed identity and service account, assigned 'storage account contribiutor' role for the managed identiy by following the tutorial for accessing key vault secret. Any referral documents for file share?

I try by mounting the file share using PV and PVC and the below POD configuration

I dont know if any other ways to achieve the same.

I see this discussion forum https://github.com/Azure/AKS/issues/3432#issuecomment-1805051548

kind: Pod
apiVersion: v1
metadata:
  name: workload-identity-pod
  namespace: default
  labels:
    azure.workload.identity/use: "true"
spec:
  serviceAccountName: workload-service-account
  containers:
    - name: oidc
      image: ghcr.io/azure/azure-workload-identity/msal-go
      env:
      - name: KEYVAULT_URL
        value: https://kvdev.vault.azure.net/
      - name: SECRET_NAME
        value: myurl
      volumeMounts:
      - mountPath: /mnt/wi
        name: azure-workload
        readOnly: false
  nodeSelector:
    kubernetes.io/os: linux
  volumes: 
    - name: azure-workload
      persistentVolumeClaim: 
        claimName: wi-pvc
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,795 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anand Prakash Yadav 7,090 Reputation points Microsoft Vendor
    2024-04-02T11:38:07.9266667+00:00

    Hello Sriramulu, Latha,

    Thank you for posting your query here!

    Please note that the Azure File CSI driver currently uses a secret (the nodeStageSecretRef) to store the storage account key. This is used to mount the file share as a persistent volume. As of now, the CSI driver might not support using Managed Identities directly.
    If you want to avoid storing the storage account key as a secret, can you try to use an init container in your Pod that uses the Managed Identity to retrieve the storage account key, and then dynamically create the secret required by the CSI driver. This way, the storage account key is not permanently stored in a Kubernetes secret.

    Do let us know if you have any further queries. I’m happy to assist you further.