Here be dragons. Use with extreme caution.
This script is designed to accept namespaces as a list of arguments and will perform a namespace child resource delete loop before terminating the namespace and any finalizers.
Having Google'd the classic StackOverflow Deleted Namespace Stuck In Pending question for the five thousandth time I decided to make this a script in a gist.
Excellent script Kat!
One addition/comment/suggestion
Even without finalizers, things may hang up due to failed volume mounts (for example due to a misconfigured CSI driver).
When that happens I end up doing something like:
and then check if there is anything funny like FailedMount, or Pending, or things like that.
Especially failed CSI volume mounts are nasty because they prevent the pods from being terminated.
When that happens I
k delete deployment $the_deployment_of_the_pending_pod
k delete po $the_pod -n $the_ns --grace-period=0 --force
I’m not sure the best way to incorporate those to this script though.
I’ll play with it when I find some time.
Cheers,
V.