Skip to main content

Stuck in Terminating state!


Geoff Burke
Forum|alt.badge.img+22

Hi Everyone,

 

I don’t remember if this has come up here before but every once in a while when deleting namespaces your deletion just hangs in a terminating state:

Where is the Terminator

Yes I am removing Kasten but only because this is a test lab for other purposes. Never delete Kasten in production if you want data protection 😉

So what is up?  I had installed via helm so this would normally not happen but I think I was tinkering and there may have been so objects left over. We can check that by running this command:

kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get -n kasten-io
Nothing found

No objects are present which is good since we don’t want to junk lying around in the cluster.

The problem when this happens is that a finalizer is present for whatever reason so you need to manually remove it. We can get the namespace manifest and check it out:

kubectl get ns kasten-io -o json >kasten.json

Let’s view the file:

There it is

We need to remove this in order for the deletion to continue.

Edit the file and remove the “kubernetes” line

The file should now look like this:

Edited File

Now we need to replace this in the cluster:

kubectl replace --raw "/api/v1/namespaces/kasten-io/finalize" -f kasten.json

You will see a lot of output from that command:

output

Now when we look for the kasten-io namespace we see that it is gone:

Gone

You may be asking just what are finalizers? In short they are there to tell system to wait while everything gets cleaned up in the namespace before deleting it. You can find a deeper dive on finalizers over on the Kubernetes official documentation page:

 

https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/

8 comments

coolsport00
Forum|alt.badge.img+20
  • Veeam Legend
  • 4133 comments
  • September 7, 2023

Nice write-up Geoff. Easy workaround to get the job done at least. Thanks for sharing!


Chris.Childerhose
Forum|alt.badge.img+21
  • Veeam Legend, Veeam Vanguard
  • 8486 comments
  • September 7, 2023

Another great Kubernetes tidbit Geoff.  👍🏼


michaelcade
Forum|alt.badge.img+7
  • Product Strategy
  • 116 comments
  • September 8, 2023

The quickest option is going to be helm uninstall even in test and demo environments. 
 

 


saintdle
Forum|alt.badge.img+3
  • Veeam Vanguard
  • 17 comments
  • September 8, 2023

There is probably some CRDs that were not cleaned up hence the finalizer getting stuck, and by removing the finalizer, they’ll still be there. Be interesting to know if that is the case, I know I’ve come across it before.


Geoff Burke
Forum|alt.badge.img+22
  • Author
  • Veeam Legend, Veeam Vanguard
  • 1318 comments
  • September 8, 2023
michaelcade wrote:

The quickest option is going to be helm uninstall even in test and demo environments. 
 

 

yup helm was used but.. I am trying to remember what I did “extra” on this install :) It is an old Linux laptop and I was tampering ;)


Geoff Burke
Forum|alt.badge.img+22
  • Author
  • Veeam Legend, Veeam Vanguard
  • 1318 comments
  • September 8, 2023
saintdle wrote:

There is probably some CRDs that were not cleaned up hence the finalizer getting stuck, and by removing the finalizer, they’ll still be there. Be interesting to know if that is the case, I know I’ve come across it before.

I should have mentioned that I did take a peak at that too 

CRD

Unless they were not showing up. But great point, CRD’s need to be checked. 


Geoff Burke
Forum|alt.badge.img+22
  • Author
  • Veeam Legend, Veeam Vanguard
  • 1318 comments
  • September 8, 2023

I wonder if the garbage collector in that case (left over objects) would have cleaned those up? 

 

https://kubernetes.io/docs/concepts/architecture/garbage-collection/


  • Comes here often
  • 11 comments
  • September 27, 2023

kubectl get crd |grep kio | awk '{print $1}'| xargs kubectl delete crd 

kubectl get apiservices |grep kio | awk '{print $1}'| xargs kubectl delete apiservices

kubectl get crd |grep kanister | awk '{print $1}'| xargs kubectl delete crd 

kubectl get apiservices |grep kanister | awk '{print $1}'| xargs kubectl delete apiservices

kubectl get apiservices |grep kanister | awk '{print $1}'| xargs kubectl delete apiservices


Comment