There are times when you want to delete a PKS Cluster, but the deletion with the usual cPKS delete-cluster command fails.
pks delete-cluster <PKS Cluster Name>
This is usually due to issues with that cluster either it failed for some reason during deployment or it was alternate into a way that destabilize it. No worry, there is a way to still force delete it and here is what I will focus on in this post. Please note you should always try to delete pks clusters using the pks delete-cluster command first and only resort to BOSH deployment delete when that does not work.
Please note in this post, I am assuming you have already setup the BOSH CLI and ready to use it. If you don’t have that setup already, I would suggest you follow the instructions at the following link.
Get your Bosh Credentials:
1- Login to PCF OPS Manager Interface
2- Click on the Installation Dashboard
3- Click on BOSH Director for vSphere
4- Click Credentials tab
5- Click on the “Link to Credentials” link next to Director Credentials
6- Keep a copy of the Director Password, as you will need it later. It will look something like below:
Force Delete PKS Cluster using Bosh:
1- SSH to your Operations Manager Appliance
2- Run the following Command to login to BOSH
$ bosh -e pks login
Use the username and Password collected earlier from BOSH Director for vSphere.
3- Now that you are logged in into Bosh and ready to execute your commands, let’s start by listing our BOSH Deployments. Collect your deployment service-instance name as demonstrated in the below screenshot
$ bosh -e pks deployments
4- Run the following command to delete the deployment/PKS Cluster. Make sure to use the id starting with service-instance rather than the one starting with pivotal-container as I saw some blog posts deleting the pivotal container service one which will actually delete your Pivotal container service and definitely not what we want.
$ bosh -e pks delete-deployment -d service-instance_8fb6d253-e6fc-4eca-850a-10306c30716f
Click Y, when asked if you want to continue and this will start the cluster deletion.