To create a snapshot of a Kubernetes volume using a Kubernetes YAML configuration file:
Create a YAML configuration file that adds a volume snapshot. In the file (see the example below for correct indentation and line breaks when specifying the keywords):
In
medadata:nameis the Persistent Volume Claim (PVC) name to store the snapshot.
In
spec:volumeSnaphotClassName: the name of the block volume snapshot class.In
source:persistentVolumeClaimNameis the PVC name for the block volume being protected.
For example:
apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: snapshot-pvc-1 spec: volumeSnapshotClassName: vastdata-snapshot source: persistentVolumeClaimName: vast-pvc-1
Apply the YAML configuration file:
kubectl apply -f vast-csi-deployment.yaml
Verify that the PVC snapshot has been created with the following command:
kubectl get vs
The output is similar to the following:
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE snapshot-pvc-1 true vast-pvc-1 0 vastdata-snapshot snapcontent-8b1627cc-d50a-4bdb-a1b4-67931d36eb85 50m 49m