This page shows how to set the default StorageClass for an
Google Distributed Cloud cluster. See also
[Storage](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.6/concepts/storage).

## Overview

Google Distributed Cloud can integrate with block or file storage by using any of
the following mechanisms:

- [VMWare vSphere Storage](https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.storage.doc/GUID-8AE88758-20C1-4873-99C7-181EF9ACFA70.html)
- [Kubernetes in-tree volume plugins](https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes)
- [Container Storage Interface (CSI)](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.6/how-to/install-csi-driver)

When you create a cluster, Google Distributed Cloud creates a Kubernetes
[StorageClass](https://kubernetes.io/docs/concepts/storage/storage-classes/)
named `standard`. 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 <var translate="no">\[CLUSTER_KUBECONFIG\]</var> 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](https://github.com/vmware/vsphere-storage-for-kubernetes/blob/master/documentation/storageclass.md).
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](https://kubernetes.io/docs/concepts/storage/persistent-volumes/)
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](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.6/how-to/install-csi-driver) in the
cluster.

This step depends on the storage vendor you're using. For CSI drivers, vendors
should provide instructions for deploying their CSI driver to a Kubernetes
cluster. A CSI driver's documentation should also include the
[driver-specific parameters](https://kubernetes.io/docs/concepts/storage/storage-classes/#the-storageclass-resource)
that you provide in your StorageClass, including the provisioner name.

When you create a StorageClass for your new appliance, you should name the
StorageClass after its properties (such as "fast" or "highly-replicated"),
rather than after the name of the specific driver or appliance behind it.
This will make it easier to have consistent storage policies across clusters and
environments.

### 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

[Create a manifest for a new StorageClass](https://kubernetes.io/docs/concepts/storage/storage-classes/).
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 <var translate="no">\[MANIFEST_FILE\]</var> is the path to your new StorageClass manifest
file.

## What's next

- [Read about Google Distributed Cloud's storage concepts](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.6/concepts/storage)

- [Install a CSI driver](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.6/how-to/install-csi-driver)