Configuring Dynamic PVs
Dynamic volume provisioning allows storage volumes to be created on demand. Dynamic volume provisioning depends on the StorageClass objects. The cluster administrator can define multiple StorageClass objects as required and specify a StorageClass that meets service requirements when declaring a PV or PVC. When applying for resources from Huawei storage devices, Huawei CSI creates storage resources that meet service requirements based on the preset StorageClass.
Configuration Description
Perform the following steps to configure and use dynamic PVs:
Preparation
Before configuring dynamic PVs, configure StorageClass by referring to Configuring a StorageClass .
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 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 configuring a dynamic PV
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: | This parameter takes effect when a PV is mounted. The default value is Filesystem. | |||
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. | |||
|
|
Table 2 ext4 capacity specifications
Table 3 XFS capacity specifications
Using a PVC
After a PVC is created, you can use the PVC to create a Pod. The following is a simple example of using a PVC. In this example, the created Pod uses the newly created mypvc.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:alpine
name: container-0
volumeMounts:
- mountPath: /tmp
name: pvc-mypvc
restartPolicy: Always
volumes:
- name: pvc-mypvc
persistentVolumeClaim:
claimName: mypvc # name of PVC
If Pods are batch created using PVCs, the Pods are in the ContainerCreating status for a long time, and the huawei-csi-node service is in the OOMKilled status, the memory of the huawei-csi-node service is insufficient. Increase the memory limit of huawei-csi-node by referring to Table 1 .