Manage storage classes
Find information about creating a storage class, deleting a storage class, and viewing existing storage classes.
Design a storage class
See here for more information on what storage classes are and how you configure them.
Create a storage class
After you have a storage class file, run the following command:
kubectl create -f <storage-class-file>
<storage-class-file>
should be replaced with your storage class file name.
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 Astra Trident will continue to manage them.
Astra 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.
|
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 Astra Trident's synchronized storage classes, run the following command:
tridentctl get storageclass
-
To view Astra 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.
You should only have one default storage class in your cluster at any given 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 Astra 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}]'