How do I mount an existing Azure Storage FileShare to a Pod running on AKS

Saminda 26 Reputation points
2023-04-11T00:44:39.22+00:00

Hello, I'm looking for an example of mounting an existing Azure File Share to a pod running on AKS. I was able to do this previously with YAML as below

      volumes:
      - azureFile:
          secretName: kube-storage-secret
          shareName: my-share
        name: my-volume-name

However, it's unclear if this has been deprecated and if I should use PV, PVC and StorageClasses. If I were to do this using a PersistantVoloumeClaim, how can I do this?

The example on the documentation here https://learn.microsoft.com/en-us/azure/aks/azure-csi-files-storage-provision is only talking about creating a new share and not how to use an existing share. Any help would be greatly appreciated. Thanks!

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.
3,292 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,205 questions
{count} votes

Accepted answer
  1. shiva patpi 13,256 Reputation points Microsoft Employee
    2023-04-12T20:16:40.19+00:00

    Hello @saminda , In the same document , you can follow below sections:

    https://learn.microsoft.com/en-us/azure/aks/azure-csi-files-storage-provision#create-a-kubernetes-secret and example YAML file

    https://learn.microsoft.com/en-us/azure/aks/azure-csi-files-storage-provision#mount-file-share-as-an-inline-volume

    I tried those steps to mount an existing azurefileshare by creating sample pod. Mainly you are looking for 3 steps:

    Step1:- Get the storage account name & Storage Account key

    Step2:- Create the secret

    kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=storageaccountname--from-literal=azurestorageaccountkey=storageaccountkey

    Step3:-

    Use the sample POD YAML file https://learn.microsoft.com/en-us/azure/aks/azure-csi-files-storage-provision#mount-file-share-as-an-inline-volume

    use the section:

     volumes:
      - name: azure
        csi:
          driver: file.csi.azure.com
          readOnly: false
          volumeAttributes:
            secretName: azure-secret  # required
            shareName: aksshare  # required
            mountOptions: "dir_mode=0777,file_mode=0777,cache=strict,actimeo=30,nosharesock"  # optional
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.