You are viewing documentation for a previous version of GKE On-Prem. View the latest documentation.

Setting the default storage class

This page shows how to set the default storage class for a GKE On-Prem cluster. See also Storage.

Overview

GKE On-Prem can integrate with block or file storage by using any of the following mechanisms:

When you create a cluster, GKE On-Prem creates a StorageClass object namedstandard. This is the default StorageClass for the cluster.

To see detailed information about the standard StorageClass, enter the following command:

kubectl --kubeconfig [CLUSTER_KUBECONFIG] get storageclass standard --output yaml

where [CLUSTER_KUBECONFIG] is the path of the kubeconfig file for your cluster.

In the output, you can see that the name of the StorageClass is standard. You can also see the storageclass.kubernetes.io/is-default-class: "true" annotation. This annotation identifies the StorageClass named standard as the default StorageClass.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  ...
  name: standard
  ...
parameters:
  datastore: HOST2-DATASTORE2
  diskformat: thin
  fstype: ext4
provisioner: kubernetes.io/vsphere-volume
reclaimPolicy: Delete
volumeBindingMode: Immediate

Your cluster can have several StorageClass objects, but only one of them can have the storageclass.kubernetes.io/is-default-class: "true" annotation and therefore be the default StorageClass.

In the preceding output, you can also see that the provisioner is kubernetes.io/vsphere-volume. This is the provisioner that takes action when a client requests a piece of storage of class standard.

Default StorageClass

When you request storage, you can specify a StorageClass. If you do not specify a StorageClass, the default StorageClass is used. For example, suppose you create a PersistentVolumeClaim 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 deploy a CSI driver to the cluster.

This step depends on the storage vendor you're using. Vendors should provide deployment instructions. For CSI, vendors should provide instructions for deploying their CSI driver to a Kubernetes cluster.

Remove the default annotation from the standard StorageClass

To open the standard StorageClass manifest in a text editor, enter the following command:

kubectl --kubeconfig [CLUSTER_KUBECONFIG] edit storageclass standard

In the text editor, remove the storageclass.kubernetes.io/is-default-class: "true" annotation. Close the text editor.

To verify that the annotation was removed, enter this command:

kubectl --kubeconfig [CLUSTER_KUBECONFIG] get storageclass standard --output yaml

Create a new StorageClass object

Create a manifest for a new StorageClass object. 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 file, and create the new StorageClass object:

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

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

What's next