Created
December 15, 2021 16:15
-
-
Save cftang0827/3e4f665b600a471954c88042e6c9dfaf to your computer and use it in GitHub Desktop.
Script to force delete namespace which hang in terminating stage in k8s cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo Force delete namespace $1 | |
kubectl get namespace $1 -o json | | |
tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | | |
kubectl replace --raw /api/v1/namespaces/$1/finalize -f - | |
echo Delete namespace $1 finish :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment