vSphere Container Storage Plug-in supports the volume snapshot and restore capabilities. You can use a snapshot to provision a new volume, pre-populated with the snapshot data. You can also restore the existing volume to a previous state represented by the snapshot.
Volume Snapshot and Restore Requirements
Your environment must meet general requirements that apply to vSphere Container Storage Plug-in. For more information, see Preparing for Installation of vSphere Container Storage Plug-in.
In addition, follow these requirements to use the volume snapshot and restore feature with vSphere Container Storage Plug-in:
CSI upstream external-snapshotter/snapshot-controller version 5.0.1 or higher.
vSphere version 7.0 Update 3 or higher.
The minimum version applies to both vCenter Server and ESXi.
Volume Snapshot CRD v1 is supported.
Volume Snapshot CRD v1beta1 and v1alpha1 are not supported.
Enable Volume Snapshot and Restore
Enable the volume snapshot and restore capabilities for vSphere Container Storage Plug-in.
Procedure
Using Volume Snapshot and Restore
After you enable the volume snapshot and restore capabilities for vSphere Container Storage Plug-in, you can create a snapshot dynamically or statically. You can also create a PVC from a volume snapshot.
To use the volume snapshot and restore feature, see the following example. In the example, the optional parameters are commented.
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: example-vanilla-rwo-filesystem-sc annotations: storageclass.kubernetes.io/is-default-class: "true" # Optional provisioner: csi.vsphere.vmware.com allowVolumeExpansion: true # Optional: only applicable to vSphere 7.0U1 and above parameters: csi.storage.k8s.io/fstype: "ext4" # datastoreurl: "ds:///vmfs/volumes/vsan:52cdfa80721ff516-ea1e993113acfc77/" # Optional Parameter # storagepolicyname: "vSAN Default Storage Policy" # Optional Parameter
Create Dynamically Provisioned Snapshots
You can dynamically provision a snapshot for vSphere Container Storage Plug-in.
Procedure
Create Pre-Provisioned Snapshots
Pre-provision a snapshot for the vSphere Container Storage Plug-in.
Prerequisites
- Ensure that an FCD snapshot is available in your vSphere environment.
Note:
- Pre-provisioned CSI snapshots are supported for CNS/FCD snapshots created using Kubernetes
VolumeSnapshot
APIs for vSphere 7.0 Update 3 and later. - Pre-provisioned CSI snapshots are not supported for FCD snapshots created using FCD APIs directly.
- Pre-provisioned CSI snapshots are supported for CNS/FCD snapshots created using Kubernetes
- Construct the snapshot handle based on the combination of FCD Volume ID and FCD Snapshot ID of the snapshot. For example, if the FCD Volume ID and FCD Snapshot ID for a FCD snapshot are
4ef058e4-d941-447d-a427-438440b7d306
and766f7158-b394-4cc1-891b-4667df0822fa
, the snapshot handle constructed is4ef058e4-d941-447d-a427-438440b7d306+766f7158-b394-4cc1-891b-4667df0822fa
. - Update the
spec.source.snapshotHandle
field in theVolumeSnapshotContent
object of the example-static-snapshot.yaml with the snapshot handle constructed in the above example.
Procedure
- ♦ Create a pre-provisioned volume snapshot.
$ kubectl apply -f example-static-snapshot.yaml $ kubectl get volumesnapshot static-vanilla-rwo-filesystem-snapshot NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE static-vanilla-rwo-filesystem-snapshot true static-vanilla-rwo-filesystem-snapshotcontent 5Gi static-vanilla-rwo-filesystem-snapshotcontent 76m 22m
Restore Volume Snapshots
You can restore a volume snapshot that is already created with vSphere Container Storage Plug-in.
Procedure
Configure Maximum Number of Snapshots per Volume
Configure the maximum number of snapshots per volume for the vSphere Container Storage Plug-in.
Parameter | Description |
---|---|
global-max-snapshots-per-block-volume |
Global configuration parameter that applies to volumes on all kinds of datastores. By default, it is set to three. |
granular-max-snapshots-per-block-volume-vsan |
Granular configuration parameter on vSAN datastore only. It overrides the global constraint if set, while it falls back to the global constraint if unset. |
granular-max-snapshots-per-block-volume-vvol |
Granular configuration parameter on Virtual Volumes datastore only. It overrides the global constraint if set. It falls back to the global constraint if unset. |
Prerequisites
- For a better performance, use two to three snapshots per virtual disk. For more information, see Best practices for using VMware snapshots in the vSphere environment.
- Ensure that the maximum number of snapshots per volume is configurable, and its default is set to three.
- The best practice guideline applies only to virtual disks on VMFS and NFS datastores while not to those on Virtual Volumes and vSAN datastores.
- Granular configuration parameters are introduced apart from the global configuration parameter.