Creating Persistent Volume in a Kubernetes cluster using NFS

To create a persistent volume you need one NFS mounted directory per server so that it can be accessed from all worker nodes.

To create a Persistent Volume use a yaml file with NFS drive configuration declared.

Sample Volume File
apiVersion: v1
kind: PersistentVolume
  name: cc-pv-volume
    type: local
    author: ccuser
  storageClassName: manual
    storage: 2Gi
    - ReadWriteMany
 # persistentVolumeReclaimPolicy: Retain
    path: /docker_volume/
    server: 111.22.333.444
    readOnly: false
Follow the steps given below to create a Persistent Volume in Kubernetes using NFS:
  1. Change storage path and server parameters in the given sample file based on your deployment configuration and save this file as, cc-pv-volume.yaml inside Kubernetes_scripts.
  2. Invoke the following commands:
    $ cd
    $ cd Kubernetes_scripts
    $ vi cc-pv-volume.yaml
  3. Copy the file content from the sample file given above into this file and save it.
    $ kubectl create -f cc-pv-volume.yaml
  4. Invoke the following command to verify if your Persistence Volume is created:
    $ kubectl get pv