Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount Azure Files' folder into Kubernetes?

As direct mount or persistent volume claim the Azure docs show how to mount an Azure Files storage account to a Kubernetes pod. This mounts the entire storage as the mounted path. How do I instead mount a folder within the Azure Files storage to Kubernetes?

On Azure Files, I have the following:

AzureFiles
|- folder1
   |- file1
|- folder2
   |- file2

When I mount the Azure Files storage account to Kubernetes (to /mnt/azure) I see this:

/mnt
|- azure
   |- folder1
      |- file1
   |- folder2
      |- file2

Instead I'd like to see this when I mount Azure Files' path folder1:

/mnt
|- azure
   |- file1

How do I change my Pod definition to specify this path:

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - // ... snip ...
    volumeMounts:
      - name: azure
        mountPath: /mnt/azure
  volumes:
  - name: azure
    azureFile:
      secretName: azure-secret
      shareName: aksshare
      readOnly: false
      // TODO: how to specify path in aksshare
like image 637
robrich Avatar asked Dec 17 '22 19:12

robrich


1 Answers

Edit

Search for several days, I figure out how to mount a sub-folder of the Azure File Share to the AKS pod. You can set the yaml file like this:

volumes:
  - name: azure
    azureFile:
      secretName: azure-secret
      shareName: share/subfolder
      readOnly: false

Just set the share name with the directory, take care, do not append / in the end. The screenshot of the result is here:

enter image description here

For more details, see Naming and Referencing Shares, Directories, Files, and Metadata.

like image 129
Charles Xu Avatar answered Dec 20 '22 08:12

Charles Xu