Bootstrap FreeKB - OpenShift - Create Storage Classes using a YAML template file
OpenShift - Create Storage Classes using a YAML template file

Updated:   |  OpenShift articles

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.

 

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 

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 381bc8 in the box below so that we can be sure you are a human.