Set up a NFS Server on a Kubernetes cluster
Note: This example is for development only. Because the NFS server is sticky to the node it is scheduled on, data shall be lost if the pod is rescheduled on another node.
- To create a NFS provisioner on your Kubernetes cluster, run the following command
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/nfs-server.yaml
- After deploying, a new service
nfs-serviceis created. The file share path is accessible at10.0.171.239. Verify if the NFS Server pod is running
$ kubectl get po nfs-server-pod
- To check if the server is working, we can statically create a
PersistentVolumeand aPersistentVolumeClaim, and mount it onto a sample pod:
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/app.yaml
Verify if the newly create deployment is Running:
$ kubectl get deploy nfs-busybox