Kubernetes : Dynamic Persistent Volume provisioning using NFS Kubernetes : Dynamic Persistent Volume provisioning using NFS kubernetes kubernetes

Kubernetes : Dynamic Persistent Volume provisioning using NFS


As of August 2020, here's how things look for NFS persistence on Kubernetes:

You can

  • Put an NFS volume on a Pod directly:
apiVersion: v1kind: Podmetadata:  name: test-pdspec:  containers:  - image: k8s.gcr.io/test-webserver    name: test-container    volumeMounts:    - mountPath: /test-pd      name: test-volume  volumes:  - name: test-volume    nfs:      path: /foo/bar      server: wherever.dns
  • Manually create a Persistent Volume backed by NFS, and mount it with a Persistent Volume Claim (PV spec shown below):
apiVersion: v1kind: PersistentVolumemetadata:  name: pv0003spec:  capacity:    storage: 5Gi  volumeMode: Filesystem  accessModes:    - ReadWriteOnce  persistentVolumeReclaimPolicy: Recycle  storageClassName: slow  mountOptions:    - hard    - nfsvers=4.1  nfs:    path: /tmp    server: 172.17.0.2
  • Use the (now deprecated) NFS PV provisioner from external-storage. This was last updated two years ago, and has been officially EOL'd, so good luck. With this route, you can make a Storage Class such as the one below to fulfill PVCs from your NFS server.
kind: StorageClassapiVersion: storage.k8s.io/v1metadata:  name: example-nfsprovisioner: example.com/nfsmountOptions:  - vers=4.1
  • Evidently, CSI is the future, and there is a NFS CSI driver. However, it doesn't support dynamic provisioning yet, so it's not really terribly useful.
    • Update (December 2020): Dynamic provisioning is apparently in the works (on master, but not released) for the CSI driver.
  • You might be able to replace external-storage's NFS provisioner with something from the community, or something you write. In researching this problem, I stumbled on a provisioner written by someone on GitHub, for example. Whether such provisioners perform well, are secure, or work at all is beyond me, but they do exist.


I'm looking into doing the same thing. I found https://github.com/kubernetes-incubator/external-storage/tree/master/nfs, which I think you based your provisioner on?

I think an nfs provider would need to create a unique directory under the path defined. I'm not really sure how this could be done.

Maybe this is better of as an github issue on the kubernetes repo.


Dynamic storage provisioning using NFS doesn't work, better use glusterfs. There's a good tutorial with fixed to common problems while setting up.http://blog.lwolf.org/post/how-i-deployed-glusterfs-cluster-to-kubernetes/