A VolumeSnapshot is a request for snapshot of a volume and similar to a PVC, while a VolumeSnapshotContent is the snapshot taken from a volume provisioned in the cluster.
Ensure that there is already a SnapshotClass.
Create a YAML config
snapshot.yaml. Specify the SnapshotClass and PVC.
# Source: snapshot.yaml apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: example-snapshot spec: volumeSnapshotClassName: iomesh-csi-driver # Specify a SnapshotClass such as `iomesh-csi-driver`. source: persistentVolumeClaimName: mongodb-data-pvc # Specify the PVC for which you want to take a snapshot such as `mongodb-data-pvc`.
Apply the YAML config to create a VolumeSnapshot.
kubectl apply -f snapshot.yaml
When the VolumeSnapshot is created, the corresponding VolumeSnapshotContent will be created by IOMesh. Run the following command to verify that they were both created.
kubectl get Volumesnapshots example-snapshot
If successful, you should see output like this:
NAME SOURCEPVC RESTORESIZE SNAPSHOTCONTENT CREATIONTIME example-snapshot mongodb-data-pvc 6Gi snapcontent-fb64d696-725b-4f1b-9847-c95e25b68b13 10h