Using K10tools to list and delete(as applicable), vsphere snapshots created by K10

This article explains how to query all the snapshots created by K10 in a vsphere cluster.

K10 directly integrates with the vsphere clusters (except vSphere with Tanzu), making use of vsphere’s govmomi libraries to take snapshots of the PVCs that are created by vsphere CSI driver.


K10 added a feature to tag all the vsphere snapshots in version 4.5.6. The feature enables K10 to create a category in the format k10:<installationId> and tag all the snapshots that it creates under this category.

K10tools uses this category to list the snapshots.


Note: Vsphere CSIdriver snapshotting capability was added to the driver in its v2.5.0 version as an alpha feature.

Prerequisite

Enable tagging in the vsphere infrastructure profile. After this feature is enabled, K10 will start tagging all the snapshots that it creates using this profile.

Configure K10tools to use the Vsphere details and list the snapshots

Step 1:

Download the K10tools binary from the github releases page.

Set environment variables before proceeding with the next steps

export VSPHERE_ENDPOINT=<url of esxi or vCenter instance to connect to>
export VSPHERE_USERNAME=<vsphere username>
export VSPHERE_PASSWORD=<vsphere password>
#category name can be found from the vsphere infrastructure profile
export VSPHERE_SNAPSHOT_TAGGING_CATEGORY=$(kubectl -n kasten-io get profiles $(kubectl -n kasten-io get profiles -o=jsonpath='{.items[?(@.spec.infra.type=="VSphere")].metadata.name}') -o jsonpath='{.spec.infra.vsphere.categoryName}')

 

Step 2:

Use the k10tools binary with the below arguments to list the snapshots

$ k10tools provider-snapshots list -t FCD
Fetching provider snapshots
[

  {

    "storageType": "FCD",

    "snapshotID": "23be48e4-6270-4154-8fc2-e59ccbdec9f5:68edaf6d-a269-463a-949e-73cbd3d924b8",

    "restorePointContentName": "pacman-manualbackup-f5m6q"

  },

  {

    "storageType": "FCD",

    "snapshotID": "23be48e4-6270-4154-8fc2-e59ccbdec9f5:0e67b006-e8d2-47ac-9510-9750008e3c0a",

    "restorePointContentName": "pacman-manualbackup-qk22f"

  }

]

 

The output gives the <volID>:<snapID> under the snapshotID field and the corresponding restorePointContentName.

 

Step 3:

To delete FCD snapshots, use values from the above snapshotID in the form <volID>:<snapID> and run -

 govc disk.snapshot.rm <volID> <snapID>

$ govc disk.snapshot.rm 23be48e4-6270-4154-8fc2-e59ccbdec9f5 68edaf6d-a269-463a-949e-73cbd3d924b8


[22-04-22 18:47:05] Deleting 68edaf6d-a269-463a-949e-73cbd3d924b8...OK