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
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:
For more details, see Naming and Referencing Shares, Directories, Files, and Metadata.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With