示例
更新時間 2025-09-23 16:29:02
最近更新時間: 2025-09-23 16:29:02
分享文章
本節展示預配置創建快照的示例。
應用場景
HBlock源卷為luna1,快照為luna1-snapshot,在CSI中創建快照csi-static-snapshot-luna1。
操作步驟
創建VolumeSnapshotContent的配置文件snapshot-content-luna1.yaml。
apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshotContent metadata: name: csi-static-snapshot-content1 spec: deletionPolicy: Delete driver: stor.csi.k8s.io source: snapshotHandle: cluster1:luna1:luna1-snapshot volumeSnapshotRef: name: csi-static-snapshot-luna1 namespace: default創建VolumeSnapshot的配置文件snapshot-static-snapshot-luna1.yaml。
apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: csi-static-snapshot-luna1 namespace: default spec: source: volumeSnapshotContentName: csi-static-snapshot-content1應用VolumeSnapshotContent和VolumeSnapshot的配置文件。
[root@k8s-master stor-examp]# kubectl apply -f snapshot-content-luna1.yaml volumesnapshotcontent.snapshot.storage.k8s.io/csi-static-snapshot-content1 created [root@k8s-master stor-examp]# kubectl apply -f snapshot-static-snapshot-luna1.yaml volumesnapshot.snapshot.storage.k8s.io/csi-static-snapshot-luna1 created查看快照。
[root@k8s-master stor-examp]# kubectl get volumesnapshots NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE csi-static-snapshot-luna1 true csi-static-snapshot-content1 1 csi-static-snapshot-content1 7m12s 8m4s