This topic describes how to use disks to create dynamic persistent volumes (PVs) in the console.

Background information

You have created a Kubernetes cluster. For more information, see Create an ACK cluster.

Create a storage class

  1. Log on to the Container Service console.
  2. In the left-side navigation pane, choose Clusters > Persistent Volumes to go to the PVs and PVCs page.
  3. On the Storage Classes tab, click Create in the upper-right corner.
    Storage Classes
    • Name: The name of the disk.
    • Provisioner: Set this parameter to Cloud Disk to indicate that the Alibaba Cloud Provsioner plug-in is used to create the storage class.
    • Parameters: In this example, the sample parameters are type and zoneid.
      • type: the disk type. Valid values: cloud, cloud_efficiency, cloud_ssd, cloud_essd, and available. If you set this parameter to available, the system tries to create a disk in the order of ultra disk, ESSD, and SSD, and stops trying until a disk is created.
      • zoneid: the zone of the disk to create.
        If you set this parameter for a multi-zone cluster, you can specify multiple zones. Example:
        zoneid: cn-hangzhou-a,cn-hangzhou-b,cn-hangzhou-c
      • encrypted: optional. Specifies whether the disk is encrypted. The default value is false, indicating that the disk is not encrypted.
    • Reclaim Policy: The policy for reclaiming the disk. The default value is Delete. You can also set this parameter to Retain. We recommend that you set this parameter to Retain to ensure data security and avoid incorrect deletion.
    • Binding Mode: Valid values: Immediate and WaitForFirstConsumer. Default value: Immediate.
    • Mount Options: When you mount a volume, you can add multiple mount options.
  4. After you complete the parameter configurations, click Create.

Create a PVC

  1. In the left-side navigation pane, choose Clusters > Persistent Volumes to go to the PVs and PVCs page.
  2. On the Persistent Volume Claims tab, click Create in the upper-right corner.
  3. Specify the parameters in the Create PVC dialog box that appears.
    Create PVC
    • Source: Use Existing PV and Use Storage Class are supported.
    • PVC Type: Cloud Disk, NAS, and OSS are supported.
      Note This option appears only when you set the Source parameter to Use Existing PV.
    • Name: The name of the PV. It must be unique in the cluster.
    • Allocation Mode: Select an existing volume.
      Note This option appears only when you set the Source parameter to Use Existing PV.
    • Existing Volumes: Click Select PV. In the Actions column corresponding to the target volume, click Select.
    • Capacity: The capacity of the PV.
      Note The capacity of the PV cannot exceed the disk capacity.
    • Access Mode: Default value: ReadWriteOnce.
      Note This option appears only when you set the Source parameter to Use Storage Class.
  4. Click Create.
    After the PVC is created, test-cloud is displayed in the list and the PVC is bound to the corresponding PV.

Use data volumes

  1. In the left-side navigation pane, choose Applications > Deployments and then click Create from Image in the upper-right corner.
  2. Set the following parameters: Name, Cluster, Namespace, Replicas, Type, Annotations, and Labels. The replicas parameter specifies the number of Pods. Click Next.
    Note In this example, set the type parameter to Deployment.

    If you do not set the Namespace parameter, the default namespace is used.

  3. Configure the container.
    This example describes how to configure a data volume. For more information about other parameters, see Create deployments by using images.
    Local volumes and cloud volumes are supported.
    • Local Volume: Supports hostPath, ConfigMaps, Secrets, and temporary directories. Local volumes mount the corresponding mount source to a path in the container. For more information, see Volumes.
    • Cloud Volume: Three types of PVs are supported: Cloud Disks, NAS, and OSS.

    This example selects a PV created from a disk and mounts the PV to the /tmp path in the container. Data generated in this path is stored to the disk.

  4. After all information is configured, click Create.
    You can use the data volume after you create it.

You can also use command lines to create dynamic PVs. For more information, see Provision Alibaba Cloud disks as dynamic volumes by using commands.