
A persistent volume (PV) is the "physical" volume (such as a hard disk drive or solid state drive) on the host machine (node) that stores your persistent data, whereas a persistent volume claim (PVC) is a reference to a persistent volume, used by a pod.
Notice that there are two volume binding modes.
- Immediate
- The Persistent Volume Claim will be immediately bound to the Persistent Volume even if there are no pods mounting the Persistent Volume Claim
- WaitForFirstConsumer
- The status of the Persistent Volume Claim will be Pending if there are no pods mounting the Persistent Volume Claim
- The status of the Persistent Volume Claim will be Bound if there is a pod mounting the Persistent Volume Claim and the Persistent Volume Claim was able to be bound to it's Persistent Volume
Let's say you have a YAML file named storageclass.yml that contains the following markup.
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: file-storage
provisioner: csi.trident.netapp.io
parameters:
storagePools: 'fsx_netapp_ontap_rosa_svm_lab:.*'
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: Immediate
Or in this example, a GP2 CSI storage class will be created.
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: gp2-csi
provisioner: ebs.csi.aws.com
parameters:
encrypted: 'true'
type: gp2
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
Or to create an AWS GP2 EBS storage class.
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: gp2
provisioner: kubernetes.io/aws-ebs
parameters:
encrypted: 'true'
type: gp2
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
Or to create a vSphere thin storage class.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: thin
parameters:
diskformat: thin
provisioner: kubernetes.io/vsphere-volume
reclaimPolicy: Delete
volumeBindingMode: Immediate
The oc apply or oc create command with the -f or --filename option can be used to create the storage class using the template JSON or YAML file.
The oc edit command can be used to update a storage class template YAML file.
~]$ oc create --filename storageclass.yml
Or in the OpenShift console at Storage > StorageClasses > Create StorageClass.

Did you find this article helpful?
If so, consider buying me a coffee over at