This topic describes how to use a static disk volume in the console.

Prerequisites

  • You have created a Kubernetes cluster. The CSI driver is deployed in the cluster.
  • You have created a pay-as-you-go disk. For more information, see Create a pay-as-you-go disk.

Create a PV

  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 Persistent Volumes tab, click Create in the upper-right corner.
    • PV Type: Supports three types of cloud storage: Cloud Disk, NAS, and OSS. In this example, select Cloud Disk.
    • Volume Plugin-in: Supports Flexvolume and CSI. In this example, select CSI.
    • Access Mode: Default is ReadWriteOnce.
    • Disk ID: Select a disk that is in the same region and zone as the cluster.
    • File System Type: Select the data type in which data is stored in the disk. Supported data types include ext4, ext3, xfs, and vfat. Default is ext4.
    • Label: Attach labels to the PV.
  4. 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. In the Create PVC dialog box that appears, set the parameters.
    • Source: Use Existing PV and Use Storage Class are supported. In this example, select Use Existing PV.
    • PVC Type: Supports three types of cloud storage: Cloud Disk, NAS, and OSS. In this example, select Cloud Disk.
      Note This option appears only when you set the Source parameter to Use Existing PV.
    • Name: The name of the PVC. 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. Find the target PV and click Select in the Actions column.
    • Capacity: The capacity of the PVC.
      Note The capacity of the PVC cannot exceed the capacity of the PV that will be bound to this PVC.
    • Access Mode: Default is ReadWriteOnce.
      Note This option appears only when you set the Source parameter to Use Storage Class.
  4. Click Create.
    After the PVC is created, you can find it on the Persistent Volume Claims page. In the following figure, the csi-disk-pvc PVC is already bound with the PV created from the previous step.

Create an application

  1. Configure the container.
    This example describes how to set the volume parameter. For more information about other parameters, see Create deployments by using images.
    Local storage and cloud storage are supported.
    • Local Storage: Supports hostPath, ConfigMaps, Secrets, and EmptyDir. You need to mount the storage to a path in the container. For more information, see Volumes.
    • Cloud Storage: Supports cloud storage.

    In this example, specify the previously created PVC and mount it to the /tmp path in the container. Data generated in this path is stored to the disk.

  2. Set the other parameters and click Create.
    After the application is created, you can use the disk volume in the application.

You can also use a static disk volume through command lines. For more information, see Use static disk volumes.