This topic describes how to use a dynamically provisioned disk volume in the Container Service for Kubernetes (ACK) console.
Prerequisites
An ACK cluster is created. For more information, see Create an ACK managed cluster.
Create a StorageClass
Log on to the ACK console.
In the left-side navigation pane of the ACK console, click Clusters.
On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
In the left-side navigation pane of the details page, choose .
On the StorageClasses page, click Create. In the Create dialog box that appears, set the following parameters:
Name: the name of the disk.
PV Type: Set the value to Cloud Disk. This specifies that the provisioner plug-in for Alibaba Cloud disks is used to create the StorageClass.
Volume Plug-in: In this example, Flexvolume is selected.
Parameter: In this example, the parameters are type and zoneid.
type: the disk type. Valid values: cloud_efficiency, cloud_ssd, cloud_essd, and available. If you set this parameter to available, the system attempts to create a disk until it succeeds. The system selects a disk type in sequence from this list: an enhanced SSD (ESSD), a standard SSD, and an ultra disk. The system keeps trying until a disk is created.
zoneid: This parameter specifies the region where the disk is created.
For a multi-zone cluster, you can specify multiple zones. Example:
zoneid: cn-hangzhou-a,cn-hangzhou-b,cn-hangzhou-c
encrypted: optional. This parameter specifies whether the disk to be created is encrypted. By default, this parameter is set to false. This specifies that the disk to be created is not encrypted.
Reclaim Policy: the policy that is used to reclaim a disk. By default, this parameter is set to Delete. You can also set this parameter to Retain. If you require higher data security, we recommend that you set this parameter to Retain to avoid data loss caused by user errors.
Binding Mode: Valid values: Immediate and WaitForFirstConsumer. Default value: Immediate.
Mount Options: When you mount a volume, you can add multiple mount options.
Click Create.
Create a PVC
Log on to the ACK console.
In the left-side navigation pane of the ACK console, click Clusters.
On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
In the left-side navigation pane of the details page, choose .
In the upper-right corner of the Persistent Volume Claims page, click Create. In the Create PVC dialog box, set the required parameters.
PVC Type: Cloud Disk, NAS, and OSS are supported. In this example, Cloud Disk is selected.
Name: the name of the persistent volume claim (PVC). The name must be unique in the namespace.
Allocation Mode: Use StorageClass, Existing Volumes, and Create Volume are supported. In this example, Use StorageClass is selected.
Existing Storage Class: Click Select. Find the StorageClass that you want to use and click Select in the Actions column.
Capacity: the capacity of the PVC.
NoteThe capacity of the PVC cannot exceed the capacity of the disk.
Access Mode: The default value is ReadWriteOnce.
Click Create.
After the PVC is created, the PVC named test-cloud appears in the list of PVCs. The PVC is associated with the specified PV.
Use the dynamically provisioned disk volume
Log on to the ACK console.
In the left-side navigation pane of the ACK console, click Clusters.
On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
In the left-side navigation pane of the details page, choose .
On the Deployments page, click Create from Image.
Set the parameters that are required to create a Deployment.
This example shows how to set the volume parameters. For more information about other parameters, see Create a stateless application by using a Deployment.
You can add local volumes and cloud volumes.
Local Storage: You can select HostPath, ConfigMap, Secret, or EmptyDir. The source directory or file is mounted to a path in the container. For more information, see Volumes.
Cloud Storage: supports the following types of persistent volumes (PVs): disks, File Storage NAS (NAS) file systems, and Object Storage Service (OSS).
In this example, a PV is created from a disk, and the PV is mounted to the /tmp path in the container. The data that is generated in this path is stored in the disk.
Set other parameters and click Create.
After the disk volume is created, you can use the disk volume.
You can also run commands to create a dynamically provisioned disk volume. For more information, see Dynamically provision a disk volume by using the CLI.