MultipleDefaultStorageClasses alert is firing in the cluster
Environment
- Red Hat Openshift Container Platform (OCP 4)
- Red Hat OpenShift Service on AWS (ROSA 4)
- Red Hat Openshift Dedicated 4 (OSD 4)
- Azure Red Hat Openshift (ARO 4)
Issue
How to fix MultipleDefaultStorageClasses alert firing in the cluster?
Resolution
To resolve this, customers with cluster-admin permissions can set the storageclass.kubernetes.io/is-default-class annotation to "false" on the storage classes they no longer need to keep as "default".
oc patch storageclass <storage-class-name> -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'
Note: You have to execute this command for all the storage classes that are currently marked as the "default" until you are left with a single default storage class.
If you need help from Red Hat, please open a support case with us by clicking here.
Root Cause
OpenShift allows administrators to define a default storage class using the storageclass.kubernetes.io/is-default-class annotation. If more than one storage class has this annotation set to "true" then MultipleDefaultStorageClasses alert is fired.
If you create a Persistent Volume Claim (PVC) without specifying a storage class in the spec section, and there are multiple default storage classes available in the cluster, then the storage class chosen for the PVC will depend on the configuration and behavior of the OpenShift cluster. OpenShift uses a specific algorithm to determine the order of preference for selecting the default storage class.
To avoid this, it is suggested to keep a single default storage class.
Diagnostic Steps
- List the available storage classes to check for multiple default storageclass:
oc get storageclass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
gp2 (default) kubernetes.io/aws-ebs Delete WaitForFirstConsumer true 267d
gp2-csi ebs.csi.aws.com Delete WaitForFirstConsumer true 267d
gp3 (default) ebs.csi.aws.com Delete WaitForFirstConsumer true 267d
gp3-csi ebs.csi.aws.com Delete WaitForFirstConsumer true 267d
nfs cluster.local/nfs-provisioner-nfs-server-provisioner Delete Immediate true 180d
- Print the YAML output of default storageclass definition and check for the storageclass.kubernetes.io/is-default-class annotation:
oc get storageclass gp3 -o yaml | grep storageclass.kubernetes.io/is-default-class
storageclass.kubernetes.io/is-default-class: "true"
oc get storageclass gp2 -o yaml | grep storageclass.kubernetes.io/is-default-class
storageclass.kubernetes.io/is-default-class: "true"
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments