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

  1. 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
    
  2. Run the following command to create a PVC using the configuration file.

    kubectl create -f mypvc.yaml
    
  3. 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
    

Table 1 PVC parameters for managing PVs

Parameter

Description

Mandatory

Default Value

Remarks

metadata.annotations

PVC object annotations. Set the following parameters:

  • Driver name/manageVolumeName: volume name on the storage.
  • Driver name/manageBackendName: name of the backend to which the volume belongs.

Yes

csi.huawei.com/manageVolumeName: * csi.huawei.com/manageBackendName: *

  • For details about how to obtain Driver name, see Table 4.
  • Driver name/manageVolumeName: name of an existing volume on the storage. Only English characters are supported.
  • Driver name/manageBackendName: name of the storage backend in CSI.

You can run the oceanctl get backend -n huawei-csi command to obtain the backend name.

metadata.labels

PVC object labels.

No

-

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.

metadata.name

User-defined name of a PVC object.

Yes

-

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.

spec.volumeMode

Volume mode. This parameter is optional. When LUN volumes are used, the following types are supported:

  • Filesystem: local file system.
  • Block: raw device.
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.

  • If a volume is used as a raw volume before being managed, volumeMode must be set to Block.
  • If a volume is used in ext2, ext3, or ext4 mode before being managed, volumeMode must be set to Filesystem and fsType in the StorageClass must be set to ext2, ext3, or ext4.
  • If a volume is used in XFS mode before being managed, volumeMode must be set to Filesystem and fsType in the StorageClass must be set to xfs.

No

Filesystem

This parameter takes effect when a PV is mounted.

  • Filesystem indicates that a container accesses a PV using a local file system. The local file system type is specified by the fsType field in the specified StorageClass.
  • Block indicates that a PV is accessed in raw volume mode.

spec.storageClassName

Name of the StorageClass object.

Yes

-

The configuration of the StorageClass must be the same as that of the managed volume.

spec.resources.requests.storage

Size of the volume to be created. The format is ***Gi and the unit is GiB.

Yes

-

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.

spec.accessModes

Access mode of the volume.

  • RWO (ReadWriteOnce): A volume can be mounted to a node in read/write mode. This mode also allows multiple Pods running on the same node to access the volume.
  • ROX (ReadOnlyMany): A volume can be mounted to multiple nodes in read-only mode.
  • RWX (ReadWriteMany): A volume can be mounted to multiple nodes in read/write mode.
  • RWOP (ReadWriteOncePod): A volume can only be mounted to a single Pod in read/write mode. Kubernetes 1.22 and later versions support this feature.

Yes

ReadWriteOnce

  • RWO/ROX/RWOP: supported by all types of volumes. RWOP is supported only by Kubernetes 1.22 and later versions. For versions earlier than Kubernetes 1.29, you need to enable this feature by following the instructions in Enabling the ReadWriteOncePod Feature Gate.
  • The support for RWX is as follows:
    • NAS storage: supported by all volumes
    • SAN storage: supported only by volumes whose volumeMode is set to Block

Using a PVC

The procedure is the same as that for Using a PVC for dynamic volume provisioning.