Storage must exist in the underlying infrastructure before it can be mounted as
a volume in OpenShift Container Platform. To provision NFS volumes, a list of NFS servers and
export paths are all that is required.
You must first create an object definition for the PV:
Example 1. PV Object Definition Using NFS
name: pv0001 (1)
storage: 5Gi (2)
- ReadWriteOnce (3)
path: /tmp (5)
server: 172.17.0.2 (6)
persistentVolumeReclaimPolicy: Recycle (7)
||The name of the volume. This is the PV identity in various
||The amount of storage allocated to this volume.
||Though this appears to be related to controlling access to the volume, it is
actually used similarly to labels and used to match a PVC to a PV. Currently, no
access rules are enforced based on the
||The volume type being used, in this case the nfs plug-in.
||The path that is exported by the NFS server.
||The host name or IP address of the NFS server.
||The reclaim policy for the PV. This defines what happens to a volume when released
from its claim. Valid options are Retain (default) and Recycle. See Reclaiming Resources.
Each NFS volume must be mountable by all schedulable nodes in the cluster.
Save the definition to a file, for example nfs-pv.yaml, and create the PV:
$ oc create -f nfs-pv.yaml
persistentvolume "pv0001" created
Verify that the PV was created:
# oc get pv
NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE
pv0001 <none> 5368709120 RWO Available 31s
The next step can be to create a persistent volume claim (PVC) which will bind
to the new PV:
Example 2. PVC Object Definition
- ReadWriteOnce (1)
storage: 1Gi (2)
||As mentioned above for PVs, the
accessModes do not enforce security, but
rather act as labels to match a PV to a PVC.
||This claim will look for PVs offering 1Gi or greater capacity.
Save the definition to a file, for example nfs-claim.yaml, and create the
# oc create -f nfs-claim.yaml