Skip to main content

Manage storage classes

Contributors juliantap netapp-aruldeepa

You can view existing storage classes, set a default storage class, identify the storage class backend, and delete storage classes.

View the existing storage classes

  • To view existing Kubernetes storage classes, run the following command:

kubectl get storageclass
  • To view Kubernetes storage class detail, run the following command:

kubectl get storageclass <storage-class> -o json
  • To view Trident's synchronized storage classes, run the following command:

tridentctl get storageclass
  • To view Trident's synchronized storage class detail, run the following command:

tridentctl get storageclass <storage-class> -o json

Set a default storage class

Kubernetes 1.6 added the ability to set a default storage class. This is the storage class that will be used to provision a Persistent Volume if a user does not specify one in a Persistent Volume Claim (PVC).

  • Define a default storage class by setting the annotation storageclass.kubernetes.io/is-default-class to true in the storage class definition. According to the specification, any other value or absence of the annotation is interpreted as false.

  • You can configure an existing storage class to be the default storage class by using the following command:

kubectl patch storageclass <storage-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  • Similarly, you can remove the default storage class annotation by using the following command:

kubectl patch storageclass <storage-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

There are also examples in the Trident installer bundle that include this annotation.

Note There should be only one default storage class in your cluster at a time. Kubernetes does not technically prevent you from having more than one, but it will behave as if there is no default storage class at all.

Identify the backend for a storage class

This is an example of the kind of questions you can answer with the JSON that tridentctl outputs for Trident backend objects. This uses the jq utility, which you may need to install first.

tridentctl get storageclass -o json | jq  '[.items[] | {storageClass: .Config.name, backends: [.storage]|unique}]'

Delete a storage class

To delete a storage class from Kubernetes, run the following command:

kubectl delete storageclass <storage-class>

<storage-class> should be replaced with your storage class.

Any persistent volumes that were created through this storage class will remain untouched, and Trident will continue to manage them.

Note Trident enforces a blank fsType for the volumes it creates. For iSCSI backends, it is recommended to enforce parameters.fsType in the StorageClass. You should delete existing StorageClasses and re-create them with parameters.fsType specified.