Cloud Native Storage (CNS) is a vSphere feature that allows Kubernetes to auto-provision scalable storage on demand. CNS also provides vSphere administrator visibility into container volumes through vCenter Server. Container Storage Interface (CSI) is part of CNS, based on First Class Disk (FCD).
This section describes how to create volume snapshots in a Kubernetes cluster and retrieve snapshot handles using CSI.
On Vanilla Kubernetes Cluster
First create a VolumeSnapshotClass as in this YAML example:
apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshotClass metadata: name: example-vanilla-rwo-filesystem-snapshotclass driver: csi.vsphere.vmware.com deletionPolicy: Delete
Run the kubectl command on this file, sample_snapshotclass.yaml in this example:
$ kubectl apply -f sample_snapshotclass.yaml
Next create a VolumeSnapshot as in this YAML example:
apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: example-vanilla-rwo-filesystem-snapshot namespace: test-ns spec: volumeSnapshotClassName: example-vanilla-rwo-filesystem-snapshotclass source: persistentVolumeClaimName: example-vanilla-rwo-pvc
Run the kubectl command on this file, sample_snapshot01.yaml in this example:
$ kubectl apply -f sample_snapshot01.yaml
This will result in VolumeSnapshot and VolumeSnapshotContent API objects. Inspect the Status field of the VolumeSnapshotContent API object to find the SnapshotHandle field.
For example, if the FCD Volume ID and FCD Snapshot ID for a FCD snapshot are the first two, the snapshot handle is a combination of the two separated by plus mark.
4ef058e4-d941-447d-a427-438440b7d306 766f7158-b394-4cc1-891b-4667df0822fa 4ef058e4-d941-447d-a427-438440b7d306+766f7158-b394-4cc1-891b-4667df0822fa
Similarly you can create a second VolumeSnapshot from the same volume and retrieve the SnapshotHandle from the VolumeSnapshotContent API object.
With the SnapshotHandle of the first and second snapshots, you can retrieve Changed Blocks using the vSphere API, as in standard CBT backup.
TKGS Cluster
If you are on a Tanzu Kubernetes Grid Service (TKGS) cluster, a VolumeSnapshotClass named volumesnapshotclass-delete
is already created for you.
Create a VolumeSnapshot as in this YAML example:
apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: example-tkgs-rwo-filesystem-snapshot namespace: test-ns spec: volumeSnapshotClassName: volumesnapshotclass-delete source: persistentVolumeClaimName: example-tkgs-rwo-pvc
Run the kubectl command on this file, sample_snapshot01.yaml in this example:
$ kubectl apply -f sample_snapshot01.yaml
This will result in VolumeSnapshot and VolumeSnapshotContent API objects. Check the following annotation of the VolumeSnapshot API object and retrieve the SnapshotHandle from <snap-id>:
"csi.vsphere.volume/snapshot": "<fcd-id>+<snap-id>"
Similarly you can create a second VolumeSnapshot from the same volume and retrieve SnapshotHandle from VolumeSnapshot annotation. With SnapshotHandle of the first and second snapshots, you can retrieve Changed Blocks using the vSphere API, as in standard CBT backup.
For more information about the CSI Snapshot feature, see topic "Volume Snapshot and Restore" in the manual Getting Started with VMware vSphere Container Storage Plug-in on docs.vmware.com.