Goglides Dev 🌱

Goglides Dev 🌱 is a community of amazing users

Shaping the future of IT, one connection at a time.

Create account Log in
Cover image for How to Configure Default Storage Class in OpenShift?
Balkrishna Pandey
Balkrishna Pandey

Posted on

How to Configure Default Storage Class in OpenShift?

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"
Enter fullscreen mode Exit fullscreen mode

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"}}}'
Enter fullscreen mode Exit fullscreen mode

Verify as follows,

oc get sc
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Discussion (0)