Pre-provisioning a VolumeSnapshot
This section describes how to pre-provision a VolumeSnapshot using Huawei CSI.
Prerequisites
- A source VolumeSnapshot has been created on the Huawei storage device, and the created snapshot name can be obtained.
Creating a VolumeSnapshot Entity
The following is an example of the VolumeSnapshotContent file:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotContent
metadata:
name: mysnapshotcontent
spec:
deletionPolicy: Retain
driver: csi.huawei.com
volumeSnapshotRef:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
name: mysnapshot
namespace: default
source:
snapshotHandle: mybackend.1.snapshot_001
volumeSnapshotClassName: "mysnapclass"
You can modify the parameters according to Table 1 .
Table 1 VolumeSnapshotContent parameters
Run the following command to create a VolumeSnapshotContent using the created VolumeSnapshotContent configuration file.
kubectl create -f mysnapshotcontent.yamlRun the following command to view the information about the created VolumeSnapshot.
kubectl get volumesnapshotcontentThe following is an example of the command output.
NAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT VOLUMESNAPSHOTNAMESPACE AGE mysnapshotcontent true 0 Retain csi.huawei.com mysnapclass mysnapshot default 4s
Creating a Snapshot for a Volume
After a VolumeSnapshotContent is created in provisioned mode, you can create a VolumeSnapshot based on the VolumeSnapshotContent. The following is an example of the VolumeSnapshot configuration file:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: mysnapshot
namespace: default
spec:
volumeSnapshotClassName: mysnapclass
source:
volumeSnapshotContentName: mysnapshotcontent
You can modify the parameters according to Table 2 .
Table 2 VolumeSnapshot parameters
Run the following command to create a VolumeSnapshot using the created VolumeSnapshot configuration file.
kubectl create -f mysnapshot.yamlRun the following command to view the information about the created VolumeSnapshot.
kubectl get volumesnapshotThe following is an example of the command output.
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE mysnapshot true mysnapshotcontent 0 mysnapclass mysnapshotcontent 2m39s 8s