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.
- Compare access to Azure Files, Blob Storage, and Azure NetApp Files with NFS
- supported OS: Linux
- When using AKS managed CSI driver, make sure cluster
Control plane
identity(with nameAKS Cluster Name
) hasContributor
permission on vnet resource group - [Optional] Create a
Premium_LRS
orPremium_ZRS
Azure storage account with following configurations to support NFS sharePremium_ZRS
account type is only supported in limited region support- account kind:
FileStorage
- Require secure transfer for REST API operations(enable HTTPS traffic only):
false
- select virtual network of agent nodes in
Firewalls and virtual networks
- specify
storageAccount
in below storage classparameters
- account kind:
- Create an Azure File storage class
specify
protocol: nfs
in 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
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true
mountOptions:
- nconnect=4
- noresvport
- actimeo=30
run 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 -h
Filesystem 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