場景:當我們刪除某個k8s 名稱空間時候,有時候會半天刪不掉,一直提示Terminating,下面介紹解決辦法:
[root@rocky01 kubeasz] # kubectl delete ns prom
[root@rocky01 ~] # kubectl get ns | grep prom
prom Terminating 6m7s
# ###
[root@rocky01 ~] # NS=prom # 注意改為要刪除的NS
[root@rocky01 ~] # kubectl get namespace $NS -o json | jq '.spec.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/$NS/finalize" -f -
[root@rocky01 ~] # kubectl get ns
NAME STATUS AGE
argo-rollouts Active 2d12h
argocd Active 13h
default Active 3d12h
ingress-nginx Active 3d9h
kube-node-lease Active 3d12h
kube-public Active 3d12h
kube-system Active 3d12h
lab Active 2d18h
media Active 36h