NFS 4.1 support for Azure Files is optimized for random access workloads with in-place data updates and provides full POSIX file system support. This page shows how to use NFS feature by Azure File CSI driver on Azure Kubernetes cluster.
- supported OS: Linux
- When using AKS managed CSI driver, make sure cluster
Control planeidentity(with nameAKS Cluster Name) hasContributorpermission on vnet resource group - [Optional] Create a
Premium_LRSorPremium_ZRSAzure storage account with following configurations to support NFS sharePremium_ZRSaccount type is only supported in limited region support- account kind:
FileStorage - secure transfer required(enable HTTPS traffic only):
false - select virtual network of agent nodes in
Firewalls and virtual networks - specify
storageAccountin below storage classparameters
- account kind:
- Create an Azure File storage class
specify
protocol: nfsin storage classparameters
for more details, refer to driver parameters
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: azurefile-csi-nfs
provisioner: file.csi.azure.com
parameters:
protocol: nfs
skuName: Premium_LRS # available values: Premium_LRS, Premium_ZRS
mountOptions:
- nconnect=8run following commands to create a storage class:
wget https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/storageclass-azurefile-nfs.yaml
# set `storageAccount` in storageclass-azurefile-nfs.yaml
kubectl create -f storageclass-azurefile-nfs.yaml- Create a deployment with NFS volume
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/nfs/statefulset.yaml- enter pod to check
kubectl exec -it statefulset-azurefile-0 -- df -hFilesystem Size Used Avail Use% Mounted on ... /dev/sda1 29G 11G 19G 37% /etc/hosts accountname.file.core.windows.net:/accountname/pvc-fa72ec43-ae64-42e4-a8a2-556606f5da38 100G 0 100G 0% /mnt/azurefile ...
- Create a Wordpress application with NFS volume
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install --set persistence.storageClass="azurefile-csi-nfs" --set persistence.size=100Gi --generate-name bitnami/wordpress