vSphere CSI – remove orphan CNS volumes from GUI

Lately I’ve been playing around with vSphere CSI driver and for those who don’t know what that is, vSphere Storage for Kubernetes, also called vSphere Cloud Provider, was introduced in 2017 and became the first vSphere storage solution for Kubernetes. The main goal of that project was to expose vSphere storage and features to Kubernetes users. The project offered an in-tree volume driver that has been actively used by various Kubernetes as a service solutions, such as PKS, OpenShift, GKE On-Prem, and so on. Cloud Native Storage (CNS) is a result of evolution and productization of vSphere Storage for Kubernetes and is also enterprise ready.

The main goal of CNS is to make vSphere and vSphere storage, including vSAN, a platform to run stateful Kubernetes workloads. vSphere has a great data path that is highly reliable, highly performant and mature for enterprise use. CNS enables access of this data path to Kubernetes and brings an understanding of Kubernetes volume and pod abstractions to vSphere. CNS was first released in vSphere 6.7 Update 3.

After creating and deleting several volumes I realized that some of the Container volumes were still showing on the GUI over the vCenter -> Monitor -> Cloud Native Storage -> Container Volumes. Because I am running vSphere 6.7U3 the above menu is just read-only so no interaction with the Volumes. This changes on vSphere 7U2 where you can perform all sort of changes to the volumes.

Container Volumes

After some invstigation on how to delete this orphan volumes I realized it was not going to be that easy. PowerCLI is still not available and I didn’t want play around with the mob.

Luckely I found GOVMOMI that is amazing on dealing with this kind of issues.

How to run it

First of all from the Menu above get the volume ID and save it, you’ll need it later on.

Volume ID

To start using GOVMOMI first you’ll have to set some variables:

$vcenter = "vCenter_FQDN"
$cred = get-credential
New-VICredentialStoreItem -Host $vcenter -User $cred.username -Password $cred.GetNetworkCredential().password
$env:GOVC_URL="https://"+$vcenter
$env:GOVC_USERNAME=(Get-VICredentialStoreItem $vcenter).User
$env:GOVC_PASSWORD=(Get-VICredentialStoreItem $vcenter).Password
$env:GOVC_INSECURE="true"
$env:GOVC_DATASTORE="DS_WHERE_THE_VOLUME_IS"

for the credentials use Administrator@vsphere.local or equivalent.

After setting all those variables over PowerCLI on my environment you can browse to the folder where you have extracted GOVMOMI and run the following command:

.\govc.exe datastore.ls

This will output the folders present on the Datastore that you defined above on GOVC_DATASTORE

Now that you’re sure you have the correct Datastore you can run the command:

.\govc.exe disk.ls

This command will output the list of Volumes that are flagged as orphaned and you can compare the volume ID and check if they are the same. If so just run

.\govc.exe disk.ls -R

And your volumes is removed from the inventory. This command will not print any output. You’ll have to wait a little bit until the GUI reflectes the changes. A refesh is also good.

Well that’s all for today folks.

KISS 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s