How to solve AzureFile mount error(22): Invalid argument inside container? How to solve AzureFile mount error(22): Invalid argument inside container? kubernetes kubernetes

How to solve AzureFile mount error(22): Invalid argument inside container?


There are two ways to consume azure file share as volume from a container in AKS

  1. Manually create and use a volume with Azure Files share. Docs here

In this case the PV need to specify mountOptions

apiVersion: v1kind: PersistentVolumemetadata:  name: azurefilespec:  capacity:    storage: 5Gi  accessModes:    - ReadWriteMany  storageClassName: azurefile  azureFile:    secretName: azure-secret    shareName: aksshare    readOnly: false  mountOptions:  - dir_mode=0777  - file_mode=0777  - uid=1000  - gid=1000  - mfsymlinks  - nobrl
  1. Dynamically create and use a persistent volume with Azure Files. Docs here

In this case StorageClass need to have mountOptions

kind: StorageClassapiVersion: storage.k8s.io/v1metadata:  name: my-azurefileprovisioner: kubernetes.io/azure-filemountOptions:  - dir_mode=0777  - file_mode=0777  - uid=0  - gid=0  - mfsymlinks  - cache=strictparameters:  skuName: Standard_LRS

Now looking at your yamls It seems you are mixing the manual and dynamic mode because you are creating both PersistentVolume and a StorageClass. I suggest to follow one of the suitable approach and have mountOptions specified properly which is mandatory for both the modes.


Problem solved!There was a problem with secret I created.It was created with kubectl apply -f secret.json and accountstoragekey wasn't encoded in base64.

Thanx to Azure Support!