All Products
Search
Document Center

Container Service for Kubernetes:Use dynamically provisioned cloud disk volumes

Last Updated:Mar 26, 2026

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:

Provision a disk volume

Complete the following steps in order:

  1. Create a StorageClass to define the disk type and provisioning behavior.

  2. Create a PVC to claim storage from the StorageClass.

  3. Deploy an application and mount the PVC.

ACK console

Step 1: Create a StorageClass

  1. Log on to the ACK console and click Clusters in the left-side navigation pane.

  2. On the Clusters page, click the target cluster name. In the left-side pane, choose Volumes > StorageClasses.

  3. In the upper-right corner of the StorageClasses page, click Create.

  4. 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 type key. 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 a zoneId parameter — for example, cn-beijing-a for a single zone or cn-beijing-a, cn-beijing-b for 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).
  5. Click Create. The new StorageClass appears on the StorageClasses page.

Step 2: Create a PVC

  1. In the left-side navigation pane of the cluster details page, choose Volumes > Persistent Volume Claims.

  2. In the upper-right corner of the Persistent Volume Claims page, click Create.

  3. 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).
  4. Click Create. The PVC appears on the Persistent Volume Claims page with a bound PV.

Step 3: Deploy an application

  1. In the left-side navigation pane of the cluster details page, choose Workloads > StatefulSets.

  2. In the upper-right corner of the StatefulSets page, click Create from Image.

  3. 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 /tmp is stored in the disk volume. For other application parameters, see Use a StatefulSet to create a stateful application.

    volume

  4. 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.

  1. Create a file named storage-class-csi.yaml with the following content:

    Parameter Required Description
    provisioner Yes Set to diskplugin.csi.alibabacloud.com. This identifies the Alibaba Cloud disk CSI provisioner.
    type Yes 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.
    encrypted No Whether to encrypt the disk. Default: false.
    reclaimPolicy Yes Controls what happens to the PV and disk when the PVC is deleted. Delete removes both automatically. Retain keeps them for manual cleanup — use Retain when data loss would be costly. Default: Delete.
    allowVolumeExpansion No Set to true to allow online disk expansion.
    volumeBindingMode No 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
  2. Apply the StorageClass:

    kubectl apply -f storage-class-csi.yaml
  3. 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

  1. Create a file named pvc-ssd.yaml with the following content:

    Parameter Required Description
    name Yes The PVC name.
    accessModes Yes The access mode for the provisioned PV.
    volumeMode No The format in which the disk is mounted. Filesystem is supported.
    storageClassName Yes The name of the StorageClass to use for provisioning.
    storage Yes 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
  2. Create the PVC:

    kubectl create -f pvc-ssd.yaml
  3. 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

  1. Create a file named pvc-dynamic.yaml with the following content:

    Parameter Description
    mountPath The path inside the container where the disk volume is mounted.
    claimName The 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.
  2. Deploy the application:

    kubectl create -f pvc-dynamic.yaml
  3. Verify the deployment in the ACK console: in the cluster details page, choose Workloads > StatefulSets. The application appears in the list.

What's next