Use dynamic cloud disk volumes from the console

Updated at:

Create a StorageClass and a Persistent Volume Claim (PVC) to dynamically provision cloud disks and mount them to a StatefulSet. Application data written to the mounted path is persisted on a cloud disk.

How it works

A PVC referencing a StorageClass triggers ACK to provision a cloud disk and create a bound Persistent Volume (PV). When a pod is scheduled, Kubernetes attaches the disk to the node and mounts it at the specified path. Deleting the PVC triggers the reclaim policy (Delete or Retain).

Prerequisites

Ensure the following:

Step 1: Create a StorageClass

A StorageClass defines the disk type, zone, and lifecycle policy for on-demand disks.

  1. Log on to the ACK console . In the left-side navigation pane, click Clusters .

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

  3. On the StorageClasses page, click Create. In the Create dialog box, configure the following parameters:

    Parameter Description
    Name The name of the StorageClass.
    PV Type Select Cloud Disk.
    Volume Plug-in Select Flexvolume.
    Parameter Key-value pairs for the provisioner. See the table below.
    Reclaim Policy What happens to the disk when the PVC is deleted. Default: Delete. Set to Retain to prevent accidental data loss.
    Binding Mode When to provision the disk. Immediate: The disk is provisioned when the PVC is created. WaitForFirstConsumer: The disk is provisioned after a pod is scheduled, which ensures that the disk is in the correct zone for multi-zone clusters. Default: Immediate.
    Mount Options Optional mount flags.

    Supported Parameter values:

    Key Description Example
    type Disk type. Valid values: cloud_efficiency (ultra disk), cloud_ssd (standard SSD), cloud_essd (Enterprise SSD), available. When set to available, the system attempts to provision a disk in this order: Enterprise SSD (ESSD), standard SSD, ultra disk. cloud_essd
    zoneid Disk zone. For multi-zone clusters, specify zones as a comma-separated list. cn-hangzhou-a,cn-hangzhou-b,cn-hangzhou-c
    encrypted (Optional) Whether to encrypt the disk. Default: false. Set to true for workloads with sensitive data. true
  4. Click Create.

Step 2: Create a PVC

A PVC requests storage from the StorageClass created in Step 1. ACK provisions the disk and binds the PVC automatically.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the target cluster and click its name. In the left-side navigation pane, choose Volumes > Persistent Volume Claims.

  3. On the Persistent Volume Claims page, click Create. In the Create PVC dialog box, configure the following parameters:

    Parameter Description
    PVC Type Supported types: Cloud Disk , File Storage NAS ( NAS ), and Object Storage Service ( OSS ). Select Cloud Disk .
    Name A unique name for the PVC within the namespace.
    Allocation Mode Three allocation modes are supported: Use StorageClass, Existing Volumes, and Create PV. Select Use StorageClass to dynamically provision a disk from the StorageClass in Step 1.
    Existing Storage Class Click Select, find the StorageClass, and click Select in the Actions column.
    Capacity The requested disk size. The capacity of the PVC cannot exceed the capacity of the disk.
    Access Mode Default: ReadWriteOnce (read-write by a single node).
  4. Click Create. The PVC test-cloud appears in the PVC list, bound to the provisioned PV.

Step 3: Create an application and mount the PVC

Mount the PVC to a StatefulSet to persist application data on the cloud disk.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the target cluster and click its name. In the left-side navigation pane, choose Workloads > StatefulSets.

  3. On the StatefulSets page, click Create from Image.

  4. Configure the volume parameters. You can add local storage, add a PersistentVolumeClaim, or add a PVC template. The following volume types are available:

    • Local Storage: HostPath, ConfigMap, Secret, or EmptyDir. Mounts host paths, node-local temporary space, or configuration data into a container. See Volumes.

    • Cloud Storage: Supports cloud disks, NAS file systems, and OSS.

    In the Volumes section, click Add PersistentVolumeClaim. Select the PVC from Step 2 as the Cloud Storage source. Set the mount path to /tmp, and leave Sub-path empty. Data written to /tmp is persisted on the cloud disk. For other parameters, see Use a StatefulSet to create a stateful application .

  5. Configure the remaining parameters and click Create.

Next steps