Setting the default StorageClass

This page shows how to set the default StorageClass for an GKE on Bare Metal cluster.

Overview

GKE on Bare Metal can integrate with block or file storage by using any of the following mechanisms:

Default StorageClass

When you request storage with a PersistentVolumeClaim (PVC), you can specify a StorageClass. If you do not specify a StorageClass, the default StorageClass is used if one is configured in the cluster. GKE on Bare Metal does not configure a default StorageClass. For example, suppose you create a PVC that does not specify a StorageClass. The volume controller will fulfill the claim according to the default StorageClass.

Changing the default StorageClass

As a cluster administrator, you might want to change the default storage class. Then all requests for storage that do not specify a StorageClass will be fulfilled according to the StorageClass of your choice. This section gives the steps for changing the default.

Deploy a new storage system

Deploy a new storage system and any software components for integrating the new storage mechanism with a Kubernetes cluster. For example, you might need to install a CSI driver in the cluster.

Mark any existing default StorageClass as non-default

Search your cluster for any existing default StorageClass if one already exists and mark it as non-default. For details, see Change the default StorageClass.

Create a new StorageClass

Create a manifest for a new StorageClass. Include the storageclass.kubernetes.io/is-default-class: "true" annotation. For example:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  ...
  name: my-storage-class
  ...
parameters:
  ...
provisioner: [MY_PROVISIONER]
...

Save your manifest as a YAML file, and create the new StorageClass:

kubectl --kubeconfig [CLUSTER_KUBECONFIG] apply -f [MANIFEST_FILE]

where [MANIFEST_FILE] is the path to your new StorageClass manifest file.

What's next