vSphere with Tanzu
Security Services Platform
Orphaned VMDKs and PVC metadata left behind after K8s cluster deletion. Since the original supervisor or workload cluster no longer exists to manage the lifecycle, these volumes become "unmanaged" and must be manually purged from the datastore.
Note: The below steps are to be performed only when there is no k8s cluster associated with the datastore and the datastore needs complete cleanup of orphaned pvcs.
If there exists a k8s cluster, the ideal way to delete pvc and pv remains to be from the cli of respective guest cluster/workload cluster.
k get pvc,pv -n namespace_namek delete pvc_complete_name -n namespace_namek delete pv_complete_name -n namespace_name
Steps to be followed for complete cleanup of the orphaned pvcs and vmdks from the datastore.
wget https://github.com/vmware/govmomi/releases/download/v0.32.0/govc_Linux_x86_64.tar.gztar -zxf govc_Linux_x86_64.tar.gzsudo mv govc /usr/local/bin/export GOVC_URL=<vCenter_FQDN>export GOVC_USERNAME=<[email protected]>export GOVC_PASSWORD=<administrator_password>export GOVC_INSECURE=truecns-vols-to-delete.txt:govc disk.ls -dc="datacenter-id" -ds="datastore-name" | awk '{print $1}' > cns-vols-to-delete.txtcat cns-vols-to-delete1.txt | xargs -n 1 govc disk.rm -dc="datacenter-id" -ds="datastore-name"