Updated on 2024-06-17 GMT+08:00

Mounting a PV

A PVC provides persistent storage management for containers in multiple clouds. The cloud storage can be mounted to containers based on actual requirements, ensuring high reliability of applications.

  • After a PVC is created on the UCS console, a PVC with the same name is automatically created in your cluster. Also a PersistentVolume (PV) is created and bound with the PVC. If you are not familiar with the relationship among PVs, PVCs, and StorageClasses in Kubernetes, see Persistent Storage.
  • You can modify or delete the PVCs automatically created by UCS on the cluster details page. However, if the PVC settings on the UCS console are not modified accordingly, the modified or deleted PVCs will be re-created by UCS. Therefore, you are advised to change the settings on the UCS console, not on the cluster details page.
  • When a non-Huawei Cloud cluster uses a PVC to mount cloud storage, the cluster provider must support StorageClasses to dynamically create PVs. Run the following command to query the StorageClass configuration and the interconnected backend storage resources of the cluster. For more information about StorageClass, see Storage Classes.
    kubectl get storageclass

Mounting a PVC to a Cloud Storage Volume

  1. Set the basic container information by referring to Creating a Deployment, Creating a StatefulSet, or Creating a DaemonSet. After setting the basic container information, click Data Storage. On the PersistentVolumeClaims (PVCs) tab page, click .

    Figure 1 Container storage configuration

  2. Select the target PVC. If no PVC is available, click Create PVC. For details about related parameters, see Creating a PVC. Click OK.
  3. Set the container mount options.

    • Set Mount Path to a path to which the data volume is mounted.
      • The container path cannot be a system directory, such as / or /var/run. Otherwise, the container may not function normally. Select an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup. Otherwise, the files will be replaced, and the container cannot start normally. As a result, the workload may not be deployed.
      • If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged.
    • Set Subpath to a path of the data volume in the Kubernetes. It is the subpath of the volume instead of the root path. If this parameter is left blank, the root path is used.
    • Set permissions.
      • Read-only: You can only read the data in the mounted volume.
      • Read-write: You can modify the volume mounted to the path. Newly written data will not be migrated if the container is migrated, which may cause data loss.

  4. You can add multiple PVCs.