This topic describes different types of StorageClass for Alibaba Cloud Container Service for Kubernetes (ACK) clusters. This topic also describes how to choose a proper StorageClass to meet your business requirements, and how to configure a default StorageClass.

StorageClass

ACK clusters support the following types of StorageClass:
  • alicloud-disk-efficiency: ultra disk.
  • alicloud-disk-ssd: SSD.
  • alicloud-disk-essd: Enhanced SSD.
  • alicloud-disk-available: a high-availability mode. In this mode, the system attempts to create an SSD in priority. If the SSD resources are exhausted, the system attempts to create an ultra disk.
    Notice For versions earlier than alicloud-csi-provisioner v1.14.8.39-0d749258-aliyun, the system attempts to create a disk in the order of Enhanced SSD, SSD, and ultra disk.
  • alicloud-disk-topology: create a cloud disk in WaitForFirstConsumer mode.

The first four types of StorageClass are suitable for single-zone clusters. The last type of StorageClass is suitable for multi-zone clusters.

When you configure a StorageClass, the following rules determine the zone where the disk is created:
  • If you set volumeBindingMode: WaitForFirstConsumer in the StorageClass configuration, a disk is created in the zone where the pod is deployed.
  • If you set volumeBindingMode: Immediate and specify only one zone in the zoneId parameter of the StorageClass configuration, a disk is created in the specified zone.
  • If you set volumeBindingMode: Immediate and specify multiple zones in the zoneId parameter of the StorageClass configuration, the system attempts to create a disk in the specified zones in a round robin manner.
  • If you set volumeBindingMode: Immediate and do not specify the zoneId parameter in the StorageClass configuration, a disk is created in the zone where the csi-provisioner is deployed.

If your cluster is deployed across zones, we recommend that you set volumeBindingMode: WaitForFirstConsumer in the StorageClass configuration. You can create a StorageClass based on the required disk type.

Default StorageClass

Kubernetes provides the default StorageClass feature. If a persistent volume claim (PVC) does not require a specific StorageClass, you can use a default StorageClass to provision a volume. For more information, see Default StorageClass.

Note
  • The default StorageClass applies to all PVCs. Exercise caution if your cluster supports multiple types of volume. For example, the default StorageClass may create a cloud disk as the persistent volume (PV) for a PVC in which a Network Attached Storage (NAS) volume is defined. Therefore, ACK clusters do not support the default StorageClass feature. If you want to configure a StorageClass, take the following steps.
  • For each cluster, you can only configure one default StorageClass. If you configure more than one StorageClasses for a cluster, the StorageClasses of the cluster become invalid.
  1. Configure a default StorageClass.
    Run the following command to set alicloud-disk-ssd as the default StorageClass.
    $ kubectl patch storageclass alicloud-disk-ssd -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
    After the default StorageClass is configured, alicloud-disk-ssd is marked as (default)
    # kubectl get sc
    NAME                          PROVISIONER                       AGE
    alicloud-disk-ssd (default)   diskplugin.csi.alibabacloud.com   96m
  2. Configure the default StorageClass.
    1. Use the following template to create a PVC without specifying a StorageClass.
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: disk-pvc
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 20Gi
      The cluster automatically creates a cloud disk as the PV based on the default StorageClass: alicloud-disk-ssd.
      # kubectl get pvc
      NAME       STATUS   VOLUME                   CAPACITY   ACCESS MODES   STORAGECLASS        AGE
      disk-pvc   Bound    d-bp18pbai447qverm3ttq   20Gi       RWO            alicloud-disk-ssd   49s

What to do next

You can run the following command to delete the default StorageClass.
$ kubectl patch storageclass alicloud-disk-ssd -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'