Create a StorageClass and PVC to auto-provision cloud disks and mount them in a StatefulSet.
How it works
A PVC referencing a StorageClass triggers ACK to provision a cloud disk and create a bound 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:
-
An ACK Serverless cluster is created.
Step 1: Create a StorageClass
A StorageClass defines the disk type, zone, and lifecycle policy for on-demand disks.
-
Log on to the ACK console. In the left-side navigation pane, click Clusters.
-
On the Clusters page, find the target cluster and click its name. In the left-side pane, choose Volumes > StorageClasses.
-
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 details 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: provisions when the PVC is created. WaitForFirstConsumer: delays until a pod is scheduled, ensuring the disk is in the correct zone for multi-zone clusters. Default: Immediate. Mount Options Optional mount flags. Supported `Parameter` values:
Key Description Example typeDisk type. Valid values: cloud_efficiency(ultra disk),cloud_ssd(standard SSD),cloud_essd(Enhanced SSD),available. When set toavailable, the system attempts to provision a disk in this order: Enhanced SSD (ESSD), standard SSD, ultra disk.cloud_essdzoneidDisk zone. For multi-zone clusters, specify zones as a comma-separated list. cn-hangzhou-a,cn-hangzhou-b,cn-hangzhou-cencrypted(Optional) Whether to encrypt the disk. Default: false. Set totruefor workloads with sensitive data.true -
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.
-
Log on to the ACK console. In the left-side navigation pane, click Clusters.
-
On the Clusters page, find the target cluster and click its name. In the left-side pane, choose Volumes > Persistent Volume Claims.
-
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, NAS, OSS. Select Cloud Disk. Name A unique name for the PVC within the namespace. Allocation Mode 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). -
Click Create. The PVC
test-cloudappears 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.
-
Log on to the ACK console. In the left-side navigation pane, click Clusters.
-
On the Clusters page, find the target cluster and click its name. In the left-side pane, choose Workloads > StatefulSets.
-
On the StatefulSets page, click Create from Image.
-
Configure the volume parameters. Two volume types are available:
-
Local Storage: HostPath, ConfigMap, Secret, or EmptyDir. Mounts host directories or files into a container. See Volumes.
-
Cloud Storage: Supports cloud disks, NAS file systems, and OSS.
Select the PVC from Step 2 as the Cloud Storage source. Set the mount path to
/tmp. Data written to/tmpis persisted on the cloud disk. For other parameters, see Create a stateless application by using a Deployment. -
-
Configure the remaining parameters and click Create.