Deleting a stuck Kubernetes namespace

TL;DR

TIL how to delete a “stubborn” namespace in Kubernetes.

The thing was simple: a kubectl delete namespace my-ns was stuck.

I’m not sure why in that particular cluster and setup, but still.

Looking around I found a way: a finalizer was waiting for something that was not happening, and was not going to happen either. So the solution was straightforward: get rid of that finalizer. Except that it’s not a solution. I mean, it unhangs the namespace and removes it, but it might leave behind stuff that might bite us eventually.

There is one interesting thread about this. The long way is thus to find all resources that prevent the namespace from being removed, and remove them gently.

Cheers!


Comments? Octodon, , GitHub, Reddit, or drop me a line!