Creating Persistent Volume Claim

A Persistent Volume Claim (PVC) is a request for storage to be claimed from existing Persistent Volumes. It will match any existing Persistent Volume based on the following criteria:
  • If storageClassName of PV is same as requesting PVC
  • Storage Capacity is same or higher than requesting PVC
  • AccessModes should be the same

If the claim matches all criteria listed above, the PV will bound with claiming PVC with Persistent Volume status as bound.

Sample PVC file
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: cc-pvc-volume
spec:
  storageClassName: manual
  accessModes:
  - ReadWriteMany
  resources:
     requests:
       storage: 2Gi
Follow the steps given below to create Persistent Volume Claim:
  1. Save this file as cc-pvc-volume.yaml inside Kubernetes_scripts.
  2. Invoke the following commands:
    $ cd
    $ cd Kubernetes_scripts
    $ vi cc-pvc-volume.yaml
  3. Copy the file content from the sample file given above into this file and save it.
    $ kubectl create -f cc-pvc-volume.yaml
  4. Invoke the following command to verify if the Persistent Volume Claim was created successfully.
    $ kubectl get pvc