I wanted mapped two file from container to Azure file:
Need to mount both of them to same file share.
I tried To use sub path but its creating the folder in the azure file but do not have file. I'm also getting error in kubernetes deployment.
error:- known: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type Back-off restarting failed container
volumeMounts:
- name: serverxml
mountPath: /test/Server.xml
subPath: Server.xml
volumes:
- name: serverxml
azureFile:
secretName: azure-fileshare-secret
shareName: customer1-uat-config
readOnly: false
where azure-fileshare-secret is having secretkey of storage.
Expected results: customer1-uat-config/test/server.log and customer1-uat-config/folder/file.txt
For your issue, you should know one point that you cannot mount the files to the Azure file share. Files cannot mount to the storage. But you can mount the folders to folders of Azure file share. You can use one file share with multiple folders in it, and then mount the folders in your container to the folders in that file share.
The setting in the yaml file like this:
volumeMounts:
- name: test
mountPath: /test
- name: folder
mountPath: /folder
volumes:
- name: test
azureFile:
secretName: azurefile-secret
shareName: aksshare/test
readOnly: false
- name: folder
azureFile:
secretName: azurefile-secret
shareName: aksshare/folder
And the screenshots of the result here: