ACK Serverless uses the Container Storage Interface (CSI) plug-in to automatically provision Alibaba Cloud disk volumes on demand. This topic walks you through creating a StorageClass, claiming storage with a persistent volume claim (PVC), and mounting the volume to a stateful application.
Use cases
Disk volumes are suited for workloads that need dedicated, high-performance block storage:
-
Stateful applications with high disk I/O requirements (for example, MySQL and Redis) that do not share data across pods
-
High-throughput log writing
-
Data persistence independent of the pod lifecycle
How dynamic provisioning works
When you create a PVC that references a StorageClass, Kubernetes automatically creates and binds a persistent volume (PV) backed by an Alibaba Cloud disk. This eliminates manual disk creation and reduces storage infrastructure overhead.
ACK Serverless clusters do not include a default StorageClass. Create one before provisioning storage.
Kubernetes supports a default StorageClass feature. If a PVC does not reference a StorageClass, Kubernetes uses the default StorageClass to provision a PV. For background on Kubernetes storage concepts, see Storage basics.
Prerequisites
Before you begin, ensure that you have:
-
An ACK Serverless cluster. See Create an ACK Serverless cluster
-
kubectl connected to the cluster. See Use kubectl to connect to an ACK cluster
-
The CSI plug-in installed. See Install and update csi-provisioner
Provision a disk volume
Complete the following steps in order:
-
Create a StorageClass to define the disk type and provisioning behavior.
-
Create a PVC to claim storage from the StorageClass.
-
Deploy an application and mount the PVC.
ACK console
Step 1: Create a StorageClass
-
Log on to the ACK console and click Clusters in the left-side navigation pane.
-
On the Clusters page, click the target cluster name. In the left-side pane, choose Volumes > StorageClasses.
-
In the upper-right corner of the StorageClasses page, click Create.
-
In the Create dialog box, configure the parameters.
Specific ECS instance types do not support ESSDs or elastic ephemeral disks. See FAQ about Elastic Block Storage.
Parameter Required Description Name Yes The name of the StorageClass. Follow the format requirements displayed in the console. PV Type Yes Select Cloud Disk. Parameter Yes Specifies the disk category using the typekey. Default:cloud_essd. Valid values:cloud_essd(Enterprise SSD),cloud_regional_disk_auto(Regional ESSDs),elastic_ephemeral_disk_premium(premium elastic ephemeral disk),elastic_ephemeral_disk_standard(standard elastic ephemeral disk),cloud_ssd(standard SSD),cloud_efficiency(ultra disk). To specify fallback categories, set multiple values in order of preference — for example,type: cloud_ssd,cloud_essd. The system tries each category in sequence and stops when a disk is created. To pin disk creation to one or more zones, add azoneIdparameter — for example,cn-beijing-afor a single zone orcn-beijing-a, cn-beijing-bfor multiple zones.Reclaim Policy Yes Controls what happens to the PV and disk when the PVC is deleted. Default: Delete (PV and disk are deleted). Set to Retain to keep the PV and disk for manual cleanup — recommended when data loss would be costly. Binding Mode No Default: Immediate (disk is created before the pod is scheduled). -
Click Create. The new StorageClass appears on the StorageClasses page.
Step 2: Create a PVC
-
In the left-side navigation pane of the cluster details page, choose Volumes > Persistent Volume Claims.
-
In the upper-right corner of the Persistent Volume Claims page, click Create.
-
In the Create PVC dialog box, configure the parameters.
Parameter Required Description PVC Type Yes Select Cloud Disk. Name Yes The PVC name. Must be unique within the namespace. Allocation Mode Yes Select Use StorageClass. Existing Storage Class Yes Click Select, find the StorageClass created in Step 1, and click Select in the Actions column. Capacity Yes The storage capacity to claim. Minimum: 20 GiB. Access Mode No Default: ReadWriteOnce (single-node read/write). -
Click Create. The PVC appears on the Persistent Volume Claims page with a bound PV.
Step 3: Deploy an application
-
In the left-side navigation pane of the cluster details page, choose Workloads > StatefulSets.
-
In the upper-right corner of the StatefulSets page, click Create from Image.
-
Configure the application. When setting up volumes, select Cloud Storage and mount the PVC created in Step 2. In this example, the disk volume is mounted to
/tmp— container data written to/tmpis stored in the disk volume. For other application parameters, see Use a StatefulSet to create a stateful application.
-
Click Create. The application is deployed and uses the disk volume for persistent storage.
kubectl
Step 1: Create a StorageClass
In multi-zone clusters, the StorageClass determines which disk type to provision before scheduling the pod.
-
Create a file named
storage-class-csi.yamlwith the following content:Parameter Required Description provisionerYes Set to diskplugin.csi.alibabacloud.com. This identifies the Alibaba Cloud disk CSI provisioner.typeYes The disk category. Valid values: cloud_auto(ESSD AutoPL disk),cloud_essd(ESSD, default),cloud_essd_entry(ESSD Entry disk),cloud_ssd(standard SSD),cloud_efficiency(ultra disk),elastic_ephemeral_disk_standard(standard elastic ephemeral disk),elastic_ephemeral_disk_premium(premium elastic ephemeral disk),cloud_regional_disk_auto(Regional ESSDs). Specify multiple values as a comma-separated fallback list. For disk selection guidance, see EBS pricing, Block storage performance, and Overview of instance families.encryptedNo Whether to encrypt the disk. Default: false.reclaimPolicyYes Controls what happens to the PV and disk when the PVC is deleted. Deleteremoves both automatically.Retainkeeps them for manual cleanup — useRetainwhen data loss would be costly. Default:Delete.allowVolumeExpansionNo Set to trueto allow online disk expansion.volumeBindingModeNo Default: Immediate(disk is provisioned before the pod is scheduled).apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: alicloud-disk-ssd-b # Use diskplugin.csi.alibabacloud.com as the provisioner for Alibaba Cloud disks. provisioner: diskplugin.csi.alibabacloud.com parameters: # Disk category fallback order: ESSD → standard SSD → ultra disk. # The system tries each value in sequence and stops when a disk is created. type: cloud_essd,cloud_ssd,cloud_efficiency # Optional. Set to "true" to encrypt the disk at rest. encrypted: "false" # Retain: keeps the PV and disk when the PVC is deleted (manual cleanup required). # Delete: removes the PV and disk automatically when the PVC is deleted. reclaimPolicy: Retain # Allows online disk expansion without downtime. allowVolumeExpansion: true # Immediate: provisions the disk before scheduling the pod. volumeBindingMode: Immediate -
Apply the StorageClass:
kubectl apply -f storage-class-csi.yaml -
Verify the StorageClass in the ACK console: log on, click Clusters, click the target cluster name, then choose Volumes > StorageClasses. The new StorageClass appears in the list.
Step 2: Create a PVC
-
Create a file named
pvc-ssd.yamlwith the following content:Parameter Required Description nameYes The PVC name. accessModesYes The access mode for the provisioned PV. volumeModeNo The format in which the disk is mounted. Filesystemis supported.storageClassNameYes The name of the StorageClass to use for provisioning. storageYes The storage capacity to claim. Minimum: 20 GiB. apiVersion: v1 kind: PersistentVolumeClaim metadata: name: disk-pvc spec: accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: 25Gi storageClassName: alicloud-disk-ssd-b -
Create the PVC:
kubectl create -f pvc-ssd.yaml -
Verify the PVC in the ACK console: in the cluster details page, choose Volumes > Persistent Volume Claims. The PVC appears in the list with a bound PV.
Step 3: Deploy an application
-
Create a file named
pvc-dynamic.yamlwith the following content:Parameter Description mountPathThe path inside the container where the disk volume is mounted. claimNameThe name of the PVC to mount. Must match the PVC created in Step 2. apiVersion: apps/v1 kind: StatefulSet metadata: name: nginx-dynamic spec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 name: web volumeMounts: - name: pvc-disk mountPath: /data # Path inside the container where the disk is mounted. volumes: - name: pvc-disk persistentVolumeClaim: claimName: disk-pvc # Must match the PVC name created in Step 2. -
Deploy the application:
kubectl create -f pvc-dynamic.yaml -
Verify the deployment in the ACK console: in the cluster details page, choose Workloads > StatefulSets. The application appears in the list.
What's next
-
If you encounter errors with disk volumes, see FAQ about disk volumes.
-
To expand a disk that is running low on capacity, see Expand disk volumes.
-
To monitor disk usage in real time, see Overview of container storage monitoring.