Managing PVs
Manage Volume Provisioning allows administrators to use resources created on storage as PVs and supports features of dynamic volumes, such as capacity expansion, snapshot, and clone. This is a custom capability of Huawei CSI. This feature applies to the following scenarios:
- In the reconstruction containerized applications, existing storage volumes need to be used.
- The Kubernetes cluster is rebuilt.
- Storage data is migrated in disaster recovery (DR) scenarios.
Manage Volume Provisioning allows existing storage resources to be managed by Kubernetes. You are not allowed to manage a storage resource for multiple times and concurrently delete or create a storage resource. When a storage resource is managed by multiple clusters, operations on the managed volume in a single cluster take effect only in the cluster and will not be synchronized to other clusters. Instead, you need to perform these operations on the managed volume in other clusters. For example, when you expand the capacity of a PVC in a cluster, the capacity of the corresponding PVC in other clusters will not be automatically expanded. In this case, you need to manually expand the capacity in other clusters by running the expansion commands in Expanding the Capacity of a PV .
Configuration Description
Perform the following steps to manage and use PVs:
Preparation
- You have registered the storage where the volume to be managed resides with CSI.
- You have logged in to the storage device to obtain the name and capacity of the volume to be managed.
- The StorageClass has been configured. For details, see Configuring a StorageClass (pay attention to the Whether the Volume Management Takes Effect field in the table).
Configuring a PVC
Prepare the PVC configuration file mypv.yaml. The following is an example. For details about other parameters, see Table 1 .
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mypvc annotations: csi.huawei.com/manageVolumeName: "*" # Enter the storage resource name. csi.huawei.com/manageBackendName: "*" # Enter the storage backend name. labels: provisioner: csi.huawei.com spec: accessModes: - ReadWriteOnce volumeMode: Filesystem storageClassName: mysc resources: requests: storage: 100Gi
Run the following command to create a PVC using the configuration file.
kubectl create -f mypvc.yaml
After a period of time, run the following command to view the information about the created PVC.
kubectl get pvc mypvc
The following is an example of the command output. If the PVC status is Bound, the PVC has been created and can be used by a Pod.
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE mypvc Bound pvc-840054d3-1d5b-4153-b73f-826f980abf9e 100Gi RWO mysc 12s
- After the PVC is created, if the PVC is in the Pending state after a long time (for example, one minute), refer to When a PVC Is Created, the PVC Is in the Pending State .
- You are advised to create or delete a maximum of 100 PVCs in a batch.
Table 1 PVC parameters for managing PVs
PVC object annotations. Set the following parameters: | csi.huawei.com/manageVolumeName: * csi.huawei.com/manageBackendName: * |
You can run the oceanctl get backend -n huawei-csi command to obtain the backend name. | ||
Format: provisioner: Driver name specified during installation Example: provisioner: csi.huawei.com This parameter takes effect when a PVC is created. It is used to listen to PVC resources and obtain information about metadata.annotations. | ||||
Take Kubernetes v1.22.1 as an example. The value can contain digits, lowercase letters, hyphens (-), and periods (.), and must start and end with a letter or digit. | ||||
Volume mode. This parameter is optional. When LUN volumes are used, the following types are supported: NOTE: This parameter takes effect when a PV is mounted. The use method of this parameter must be the same as that of the managed volume.
| This parameter takes effect when a PV is mounted. | |||
The configuration of the StorageClass must be the same as that of the managed volume. | ||||
Size of the volume to be created. The format is ***Gi and the unit is GiB. | The PVC capacity depends on storage specifications and host specifications. For example, OceanStor Dorado 6.1.2 or OceanStor Pacific series 8.1.0 is connected to CentOS 7. If ext4 file systems are used, see Table 2. If XFS file systems are used, see Table 3. If NFS or raw devices are used, the capacity must meet the specifications of the used Huawei storage device model and version. If the PVC capacity does not meet the specifications, a PVC or Pod may fail to be created due to the limitations of storage specifications or host file system specifications. | |||
|
|
Using a PVC
The procedure is the same as that for Using a PVC for dynamic volume provisioning.