动态创建快照 本节主要介绍动态创建快照的步骤。 前提条件 已经创建HBlock相关的PVC,且对应的HBlock卷为Local模式。 在执行此操作之前,请确保源卷的所有数据已持久化,即如果源卷已被客户端挂载,需确保客户端的数据都已经同步到卷上。创建快照前: 如果是block模式的卷:在客户端执行sync命令。 如果是filesystem模式的卷:如果客户端支持sync f(可以通过sync help命令查看是否支持),在客户端执行sync f命令;否则在客户端执行sync命令。 操作步骤 1. 创建VolumeSnapshotClass的YAML配置文件。 plaintext apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshotClass metadata: If there is a conflict with other VolumeSnapshotClass, you can change it to another name name: csidynamicsnapclass Set to the actual driver name driver: stor.csi.k8s.io deletionPolicy: Delete VolumeSnapshotClass的YAML配置文件参数: 参数 描述 是否必填 metadata.name VolumeSnapshotClass的名称。 是 driver HBlock CSI驱动名称。 取值:HBlock CSI安装时的驱动名称。 是 2. 创建VolumeSnapshot的YAML配置文件。 plaintext apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: csidynamicsnapshot Set to the actual namespace namespace: default spec: If there is a conflict with other VolumeSnapshotClass, you can change it to another name volumeSnapshotClassName: csidynamicsnapclass source: persistentVolumeClaimName: csipvclocal VolumeSnapshot的YAML配置文件参数: 参数 描述 是否必填 metadata.name CSI中快照的名称。 是 metadata.namespace 命名空间。 取值:HBlock CSI安装时绑定的Kubernetes命名空间名称。 是 spec.volumeSnapshotClassName VolumeSnapshotClass的名称。 是 spec.source.persistentVolumeClaimName CSI中PVC的名字。 是 3. 应用VolumeSnapshotContent和VolumeSnapshot的配置文件。 plaintext kubectl apply f VolumeSnapshotClass.yaml kubectl apply f VolumeSnapshot.yaml 4. 查看快照。 plaintext kubectl get volumesnapshot [snapshotName] [ n namespace ] kubectl describe volumesnapshot snapshotName [ n namespace ]