We already have managed NFS service solution on AKS: Use Azure NetApp Files with AKS. This page shows a cost effective NFS solution(unamanged) on AKS.
NFS Server Provisioner is an out-of-tree dynamic provisioner for Kubernetes. You can use it to quickly & easily deploy shared storage that works almost anywhere. This doc shows how to set up NFS Server Provisioner on AKS using NFS Server Provisioner helm chart, the NFS server data is stored on single Azure managed disk. To get high availability, you may use Rook, step-by-step doc: Using Rook/Ceph with PVCs on AKS or Azure NetApp Files with AKS - static provisioning
- following example would provision 100GB storage(one data disk) on an agent node, serving as a NFSv3 server
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm install stable/nfs-server-provisioner --generate-name --set=persistence.storageClass=default,persistence.enabled=true,persistence.size=100Gi
# kubectl describe sc nfs
Name: nfs
IsDefaultClass: No
Annotations: <none>
Provisioner: cluster.local/nfs-server-provisioner-1587007822
Parameters: <none>
AllowVolumeExpansion: True
MountOptions:
vers=3
ReclaimPolicy: Delete
VolumeBindingMode: Immediate
Events: <none>
kubectl create -f https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/nfs/statefulset-nfs.yaml
- enter the pod container to validate
# kubectl exec -it statefulset-nfs-0 bash
root@statefulset-nfs-0:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 97G 11G 87G 11% /
tmpfs 64M 0 64M 0% /dev
tmpfs 3.4G 0 3.4G 0% /sys/fs/cgroup
10.0.212.68:/export/pvc-c08bb76e-6d45-452a-8333-53b13bd01000 99G 60M 99G 1% /mnt/nfs
/dev/sda1 97G 11G 87G 11% /etc/hosts
...
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install --set persistence.storageClass="nfs" --generate-name bitnami/wordpress
- check wordpress pods status
# kubectl get po
NAME READY STATUS RESTARTS AGE
nfs-server-provisioner-1587040611-0 1/1 Running 0 15m
wordpress-1587040914-5659b7f8db-xl44v 1/1 Running 1 10m
wordpress-1587040914-mariadb-0 1/1 Running 0 10m
- nfs server performance in writing small files scenario
time ( wget -qO- https://wordpress.org/latest.tar.gz | tar xvz -C /mnt/nfs )
real 0m16.286s
user 0m0.429s
sys 0m1.214s