Dynamically Provisioning a VolumeSnapshot

This section describes how to dynamically provision a VolumeSnapshot using Huawei CSI.

Prerequisites

  • The source PVC exists, and the backend where the PVC resides supports VolumeSnapshot creation.

Creating a Snapshot for a Volume

The following is an example of the VolumeSnapshot configuration file:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: mysnapshot
spec:
  volumeSnapshotClassName: mysnapclass
  source:
    persistentVolumeClaimName: mypvc

You can modify the parameters according to Table 1 .

Table 1 VolumeSnapshot parameters

Parameter

Description

Remarks

metadata.name

User-defined name of a VolumeSnapshot object.

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.volumeSnapshotClassName

Name of the VolumeSnapshotClass object.

--

spec.source.persistentVolumeClaimName

Name of the source PVC object.

Name of the source PVC of the snapshot

  1. Run the following command to create a VolumeSnapshot using the created VolumeSnapshot configuration file.

    kubectl create -f mysnapshot.yaml
    
  2. Run the following command to view the information about the created VolumeSnapshot.

    kubectl get volumesnapshot
    

    The following is an example of the command output.

    NAME         READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT   RESTORESIZE   SNAPSHOTCLASS   SNAPSHOTCONTENT                                    CREATIONTIME   AGE
    mysnapshot   true         mypvc                               100Gi         mysnapclass     snapcontent-1009af0a-24c2-4435-861c-516224503f2d   <invalid>      78s