This topic describes how to dynamically create and use a cloud disk volume for a stateful application on the Container Service for Kubernetes (ACK) console. It covers how to create a StorageClass, request storage with a Persistent Volume Claim (PVC), and mount the volume to a workload.
Prerequisites
You have an ACK cluster. For more information, see Create an ACK managed cluster.
Step 1: Create a StorageClass
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
On the StorageClasses page, click Create. In the Create dialog box, set the following parameters.
-
Name: The name of the StorageClass.
-
PV Type: Select Cloud Disk for this example.
-
Volume Plug-in: Select Flexvolume for this example.
-
Parameter: In this example, the parameters include type and zoneid.
-
type: Specifies the type of cloud disk. Valid values are
cloud_efficiency(ultra disk),cloud_ssd(standard SSD), andcloud_essd(enhanced SSD). If you set this parameter toavailable, the system attempts to create an enhanced SSD (ESSD), a standard SSD, and an ultra disk in sequence until a cloud disk is successfully created. -
zoneid: The zone where the cloud disk will be created.
zoneid: cn-hangzhou-a,cn-hangzhou-b,cn-hangzhou-c -
encrypted: Optional. Specifies whether to encrypt the cloud disk. By default, the disk is not encrypted (
false).
-
-
Reclaim Policy: Specifies the reclaim policy for the cloud disk. The default value is
Delete.Retainis also supported. We recommend usingRetainfor mission-critical data to prevent accidental data loss. -
Binding Mode: The default value is
Immediate.WaitForFirstConsumeris also supported. -
Mount Options: Specifies additional options for mounting the volume.
-
-
After you configure the parameters, click Create.
Step 2: Create a PVC
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
On the Persistent Volume Claims page, click Create. In the Create PVC dialog box, set the following parameters.
-
PVC Type: Supported types are Cloud Disk, NAS, and OSS. For this example, select Cloud Disk.
-
Name: The name of the PVC. The name must be unique within the cluster.
-
Allocation Mode: Supported modes are Use StorageClass, Existing Volumes, and Create PV. For this example, select Use StorageClass.
-
Existing Storage Class: Click Select Storage Class. In the Select Storage Class dialog box, click Select Node in the Actions column of the target StorageClass.
-
Capacity: The capacity of the volume.
NoteThe requested capacity must be within the limits of the selected cloud disk type.
-
Access Mode: The default value is
ReadWriteOnce.
-
-
Click Create.
After the PVC is created, it appears in the list and is bound to a corresponding volume.
Step 3: Create a workload and mount the volume
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
On the StatefulSets page, click Create from Image.
-
Configure the StatefulSet.
This section focuses on volume configuration. For information about other parameters, see Create a StatefulSet.
You can add local storage, add a PersistentVolumeClaim, or add a PVC template.
In this example, a cloud disk volume is configured and mounted to the
/tmpdirectory in the container. Data written to this directory is stored on the cloud disk. In the Volumes section, click Add PersistentVolumeClaim. Set PV Type to Cloud Storage, select the PVC you created for Mount Source, set Mount Path to/tmp, and leave Sub-path empty. -
After you configure all the parameters, click Create.
After the workload is created, the volume is mounted and ready for use.
You can also use the CLI to dynamically provision a cloud disk volume. For more information, see Use a dynamically provisioned cloud disk volume by using the CLI.