This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Managing a StorageClass

1 - Querying a StorageClass

  1. Run the following command to view the information about the created StorageClass.

    kubectl get sc mysc
    

    The following is an example of the command output.

    NAME   PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
    mysc   csi.huawei.com   Delete          Immediate           true                   8s
    

2 - Modifying a StorageClass

Kubernetes allows only the allowVolumeExpansion field of a StorageClass to be modified. The modification method is as follows:

  1. Run the following command to check whether the StorageClass can be expanded:

    kubectl get sc mysc
    

    If the command output is displayed as the following example, the StorageClass mysc cannot be expanded:

    NAME   PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
    mysc   csi.huawei.com   Delete          Immediate           false                  8s
    
  2. Run the following command to enable capacity expansion for the StorageClass:

    kubectl patch sc mysc --patch '{"allowVolumeExpansion":true}'
    
  3. Check the StorageClass again and ensure that the modification is successful.

    NAME   PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
    mysc   csi.huawei.com   Delete          Immediate           true                   8s
    

3 - Deleting a StorageClass

  1. Run the following command to view the StorageClass:

    kubectl get sc mysc
    

    The following is an example of the command output.

    NAME   PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
    mysc   csi.huawei.com   Delete          Immediate           false                  8s
    
  2. Run the following command to delete the StorageClass:

    kubectl delete sc mysc
    

    If the following information is displayed, the deletion is successful:

    storageclass.storage.k8s.io "mysc" deleted