NFS-backed storage
Abstract
Section titled “Abstract”Our default Rijkswaterstaat (VSphere) storage backend does not allow for multiple pods to mount a single persistent volume.
However, applications sometimes require such functionality.
This is made possible by using NFS-backed PV(C)s with the help of the NFS Subdir External Provisioner.
NFS backed PVC with random folder
Section titled “NFS backed PVC with random folder”To create and use a PV like that, one can create a PVC using the nfs storage class, created by the NFS provider:
kind: PersistentVolumeClaimapiVersion: v1metadata: name: test-pvcspec: storageClassName: nfs accessModes: - ReadWriteMany resources: requests: storage: 1MiThis will give you a PVC that can be mounted by multiple pods. The backing storage is a directory on the dedicated NFS share. This directory is automatically created by the NFS provisioner.
However, you will not know exactly where is the persistent data stored on the NFS share, i.e. what is the name of that directory.
This may be problematic when you want off-cluster processes to store data that your application can use, or if you want to share data between namespaces.
NFS backed PVC with dedicated folder
Section titled “NFS backed PVC with dedicated folder”In this situation, it is possible to provide the nfs.io/storage-path annotation to the PVC that directs the provisioner to point your PVC to a particular directory on the NFS share:
kind: PersistentVolumeClaimapiVersion: v1metadata: name: test-pvcannotations: nfs.io/storage-path: "directory-name"spec: storageClassName: nfs accessModes: - ReadWriteMany resources: requests: storage: 1MiSettings NFS provisioner
Section titled “Settings NFS provisioner”By default, all NFS provisioners run with the onDelete: retain setting, which means that when the PVC is deleted, the directory that backs the PV will not be removed from the NFS share.
If you create the PVC with the same storage path as before, the provisioner will not create a new directory, but will reuse the existing one.
