Create a StorageClass

Updated at:

This topic describes how to create a StorageClass.

AKS supports the following two types of storage classes:

Note

In the current Agile Platform as a Service (PaaS) environment, AKS is not integrated with Alibaba Cloud NAS or cloud disk storage. To use storage features, you must install a third-party storage plugin.

NAS type

Important

A NAS StorageClass must be in the same region as the AKS cluster nodes.

The following shows the definition of a NAS StorageClass in AKS:

apiVersion: storage.k8s.io/v1                                                                                                     
kind: StorageClass
metadata:
    name: csi-nas
provisioner: antcloud-csi
parameters:
    # region is not required
    storage_type: "cloud_nas" # Allowed enum: cloud_disk, cloud_nas, cloud_oss

    # filesystem parameters
    nasType: "Capacity"         # Allowed enum: Capacity, Performance, Extreme *
    protocolType: "NFS"             # Allowed enum: NFS, SMB *
    fileSystemDescription: "balala" # Optional

    # mountTarget parameters
    # accessGroupName: "classic-test" # The name of the default access group. This parameter has been removed.
    # networkType: Vpc                # Allowed enum: Vpc, Classic. Only Vpc is currently supported. RMC performs a database query.
    # vSwitchId: "vsw-2zevmwkwyztjuoffgdiwl"  # vSwitch ID, used in a VPC network *
    # vpcId: "vpc-2zesj9afh3y518k9oe86q" # VPC ID, used in a VPC network *

    # accessGroup parameters. The current solution uses the default access group, so these parameters are not required.

    serviceId: "1c7aff75-8b4f-4d2c-8dac-74af0b830d86-aliyun-nas-service-id"
    planId: "44dd37f1-77f9-42c5-91a5-743c007ba484-aliyun-nas-plan-id"
    accessModes: "ReadWriteMany"  # * 

reclaimPolicy: Retain # Allowed enum: Delete, Retain
volumeBindingMode: Immediate # Allowed enum: Immediate, WaitForFirstConsumer

Parameter descriptions

Parameter name

Description

Required

Notes

provisioner

antcloud-csi

Yes

The name of the AKS dynamic volume controller. This parameter cannot be changed.

storage_type

The backend storage type, such as block storage or file storage.

Yes

Only the following values are supported:

  • cloud_disk: indicates an Alibaba Cloud disk.

  • cloud_nas: indicates Alibaba Cloud NAS.

nasType

The NAS type.

Yes

Valid values:

protocolType

The file system type.

No

Only NFS is supported.

readOnly

Read-only

No

Valid values: true, false

serviceId

A required parameter for the service broker.

Yes

Must be: 1c7aff75-8b4f-4d2c-8dac-74af0b830d86-aliyun-nas-service-id

planId

A required parameter for the service broker.

No

Must be: 44dd37f1-77f9-42c5-91a5-743c007ba484-aliyun-nas-plan-id

reclaimPolicy

The reclaim policy.

Yes

  • Retain: Retains the backend storage. Deleting the persistent volume (PV) or persistent volume claim (PVC) does not delete the corresponding backend storage, such as a cloud disk. For more information, see the Kubernetes official documentation.

  • Delete: When you delete the PVC, the PV and the backend storage are automatically deleted. For more information, see the Kubernetes official documentation.

volumeBindingMode

The volume binding policy.

Yes

Controls volume binding and dynamic provisioning behavior.

  • Immediate: Creates the backend storage volume and binds the new PV to the PVC immediately after the PVC is created.

  • WaitForFirstConsumer: Creates the PV and backend storage and binds the PV to the PVC only when a pod uses the PVC. If you enable this mode, the zone and region specified in the StorageClass are ignored. Instead, the zone and region of the node where the pod is scheduled are used to create the file system. This ensures that the file system can be mounted by the pod.

Cloud disk (cloud_disk) type

Important

A cloud disk StorageClass must be in the same region and zone as the AKS cluster nodes.

The following shows the definition of a cloud disk StorageClass in AKS:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: csi-disk-ssd
provisioner: antcloud-csi
parameters:
    fsType: "ext4"
    storage_type: "cloud_disk" # Allowed enum: cloud_disk, cloud_nas, cloud_oss
    type: "cloud_ssd"
    serviceId: "8814fddf-5be7-4f8a-862c-f4a57c25a0b4-aliyun-disk-service-id"
    planId: "02b41c80-915f-43cd-a574-e9cd446f13ea-aliyun-disk-plan-id"
reclaimPolicy: Retain # Allowed enum: Delete, Retain
volumeBindingMode: WaitForFirstConsumer # Allowed enum: Immediate, WaitForFirstConsumer

Parameter descriptions

Parameter name

Description

Required

Notes

provisioner

antcloud-csi

Yes

The name of the dynamic volume controller. This parameter cannot be changed.

failure-domain.beta.kubernetes.io/region

The region.

No

This field is required when volumeBindingMode is set to Immediate. It is used to create the cloud disk. Example: CN-SHANGHAI, which indicates the China (Shanghai) region.

failure-domain.beta.kubernetes.io/zone

The zone.

No

This field is required when volumeBindingMode is set to Immediate. It is used to create the cloud disk. Example: CN-SHANGHAI-A, which indicates Zone A in the China (Shanghai) region.

fsType

The partition format.

No

Supports ext4 and ext3. The default is ext4.

storage_type

The backend storage type.

Yes

  • cloud_disk: indicates an Alibaba Cloud disk.

  • cloud_nas: indicates Alibaba Cloud NAS.

type

The disk type.

Yes

Valid values: cloud_ssd, cloud_efficiency, and cloud. For more information, see Cloud disk overview.

readOnly

Specifies whether the volume is read-only.

No

Valid values: true, false.

serviceId

A required parameter for the service broker.

Yes

Must be: 8814fddf-5be7-4f8a-862c-f4a57c25a0b4-aliyun-disk-service-id

planId

A required parameter for the service broker.

No

Must be: 02b41c80-915f-43cd-a574-e9cd446f13ea-aliyun-disk-plan-id

reclaimPolicy

The reclaim policy.

Yes

  • Retain: Retains the backend storage. Deleting the PV or PVC does not delete the corresponding backend storage, such as a cloud disk. For more information, see the Kubernetes official documentation.

  • Delete: When you delete the PVC, the PV and the backend storage are automatically deleted. For more information, see the Kubernetes official documentation.

volumeBindingMode

The volume binding policy.

Yes

Controls volume binding and dynamic provisioning behavior.

  • Immediate: Creates the backend storage volume and binds the new PV to the PVC immediately after the PVC is created.

  • WaitForFirstConsumer: Creates the PV and backend storage and binds the PV to the PVC only when a pod uses the PVC. If you enable this mode, the zone and region specified in the StorageClass are ignored. Instead, the zone and region of the node where the pod is scheduled are used to create the cloud disk. This ensures that the cloud disk can be mounted by the pod.

Prerequisites

You must have administrative permissions for AKS.

Procedure

  1. Log on to the containerized application service console. In the navigation pane on the left, click Storage > StorageClass.

  2. On the StorageClass page, click Create StorageClass. Enter the YAML content in the input box and click Submit.