Setting the default storage class in Kubernetes can be accomplished through editing the storage class YAML file or using the patch command. Simply add the following annotation to the desired storage class YAML:
annotations:
storageclass.kubernetes.io/is-default-class: "true"
This will mark the storage class as the default class in your OpenShift cluster, allowing it to be automatically used by any Persistent Volume Claims that do not specify a storage class.
You can also use the patch command to modify an existing storage class in OpenShift. Here's an example patch command that modifies the ocs-storagecluster-ceph-rbd
storage class:
oc patch storageclass ocs-storagecluster-ceph-rbd -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'
Verify as follows,
oc get sc
Output:
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-vs kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 74m
ocs-storagecluster-ceph-rbd (default) openshift-storage.rbd.csi.ceph.com Delete Immediate true 65m
ocs-storagecluster-ceph-rgw openshift-storage.ceph.rook.io/bucket Delete Immediate false 72m
ocs-storagecluster-cephfs openshift-storage.cephfs.csi.ceph.com Delete Immediate true 65m
openshift-storage.noobaa.io openshift-storage.noobaa.io/obc Delete Immediate false 62m
Top comments (0)