VolumeSnapshotClassVolumeSnapshotClass object:apiVersion: snapshot.storage.k8s.io/v1beta1kind: VolumeSnapshotClassmetadata:name: cbs-snapclassdriver: com.tencent.cloud.csi.cbsdeletionPolicy: Delete
VolumeSnapshotClass is created successfully:$ kubectl get volumesnapshotclassNAME DRIVER DELETIONPOLICY AGEcbs-snapclass com.tencent.cloud.csi.cbs Delete 17m
VolumeSnapshotnew-snapshot-demo as an example to use the following YAML to create a VolumeSnapshot object.apiVersion: snapshot.storage.k8s.io/v1beta1kind: VolumeSnapshotmetadata:name: new-snapshot-demospec:volumeSnapshotClassName: cbs-snapclasssource:persistentVolumeClaimName: csi-pvc
Volumesnapshot and Volumesnapshotcontent objects have been created successfully. If READYTOUSE is true, the creation is successful.$ kubectl get volumesnapshotNAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGEnew-snapshot-demo true www1-ivantestweb-0 10Gi cbs-snapclass snapcontent-ea11a797-d438-4410-ae21-41d9147fe610 22m 22m
$ kubectl get volumesnapshotcontentNAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT AGEsnapcontent-ea11a797-d438-4410-ae21-41d9147fe610 true 10737418240 Delete com.tencent.cloud.csi.cbs cbs-snapclass new-snapshot-demo 22m
Volumesnapshotcontent object. The field is status.snapshotHandle (here takes snap-e406fc9m as an example). You can log in to the CVM console > Snapshot List and use the snapshot ID to check whether the snapshot exists, as shown below:$ kubectl get volumesnapshotcontent snapcontent-ea11a797-d438-4410-ae21-41d9147fe610 -oyaml
apiVersion: snapshot.storage.k8s.io/v1beta1kind: VolumeSnapshotContentmetadata:creationTimestamp: "2020-11-04T08:58:39Z"finalizers:- snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protectionname: snapcontent-ea11a797-d438-4410-ae21-41d9147fe610resourceVersion: "471437790"selfLink: /apis/snapshot.storage.k8s.io/v1beta1/volumesnapshotcontents/snapcontent-ea11a797-d438-4410-ae21-41d9147fe610uid: 70d0390b-79b8-4276-aa79-a32e3bdef3d6spec:deletionPolicy: Deletedriver: com.tencent.cloud.csi.cbssource:volumeHandle: disk-7z32tin5volumeSnapshotClassName: cbs-snapclassvolumeSnapshotRef:apiVersion: snapshot.storage.k8s.io/v1beta1kind: VolumeSnapshotname: new-snapshot-demonamespace: defaultresourceVersion: "471418661"uid: ea11a797-d438-4410-ae21-41d9147fe610status:creationTime: 1604480319000000000readyToUse: truerestoreSize: 10737418240snapshotHandle: snap-e406fc9m
VolumeSnapshot object new-snapshot-demo created in the previous step as an example and uses the following YAML to restore volume from the snapshot.apiVersion: v1kind: PersistentVolumeClaimmetadata:name: restore-testspec:storageClassName: cbs-csidataSource:name: new-snapshot-demokind: VolumeSnapshotapiGroup: snapshot.storage.k8s.ioaccessModes:- ReadWriteOnceresources:requests:storage: 10Gi
diskid in the PV (here takes disk-gahz1kw1 as an example).$ kubectl get pvc restore-testNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGErestore-test Bound pvc-80b98084-29a3-4a38-a96c-2f284042cf4f 10Gi RWO cbs-csi 97s
$ kubectl get pv pvc-80b98084-29a3-4a38-a96c-2f284042cf4f -oyaml
apiVersion: v1kind: PersistentVolumemetadata:annotations:pv.kubernetes.io/provisioned-by: com.tencent.cloud.csi.cbscreationTimestamp: "2020-11-04T12:08:25Z"finalizers:- kubernetes.io/pv-protectionname: pvc-80b98084-29a3-4a38-a96c-2f284042cf4fresourceVersion: "474676883"selfLink: /api/v1/persistentvolumes/pvc-80b98084-29a3-4a38-a96c-2f284042cf4fuid: 5321df93-5f21-4895-bafc-71538d50293aspec:accessModes:- ReadWriteOncecapacity:storage: 10GiclaimRef:apiVersion: v1kind: PersistentVolumeClaimname: restore-testnamespace: defaultresourceVersion: "474675088"uid: 80b98084-29a3-4a38-a96c-2f284042cf4fcsi:driver: com.tencent.cloud.csi.cbsfsType: ext4volumeAttributes:diskType: CLOUD_PREMIUMstorage.kubernetes.io/csiProvisionerIdentity: 1604478835151-8081-com.tencent.cloud.csi.cbsvolumeHandle: disk-gahz1kw1nodeAffinity:required:nodeSelectorTerms:- matchExpressions:- key: topology.com.tencent.cloud.csi.cbs/zoneoperator: Invalues:- ap-beijing-2persistentVolumeReclaimPolicy: DeletestorageClassName: cbs-csivolumeMode: Filesystemstatus:phase: Bound
StorageClass uses topology awareness (to schedule the Pod before creating the PV), that is, to specify volumeBindingMode: WaitForFirstConsumer, you need to deploy the Pod (mount the PVC) to trigger the PV creation (create a CBS from the snapshot and bind it to the PV).Feedback