skip to Main Content

Kubernetes namespace is stuck in terminating status.

This usually happens due to the finalizer

$ kubectl get ns
NAME             STATUS        AGE
cert-manager     Active        14d
custom-metrics   Terminating   7d
default          Active        222d
nfs-share        Active        15d
ingress-nginx    Active        103d
kube-public      Active        222d
kube-system      Active        222d
lb               Terminating   4d
monitoring       Terminating   6d
production       Active        221d

3

Answers


  1. Chosen as BEST ANSWER

    This worked for me :

    kubectl get namespace linkerd -o json > linkerd.json

    Where:/api/v1/namespaces/<your_namespace_here>/finalize

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


  2. This is what worked for me:

    kubectl get namespace monitoring -o json > monitoring.json

    remove "kubernetes" from finalizers array.

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

    Login or Signup to reply.
  3. I have made this a script which is handy for me.

    for i in $(kubectl get namespaces | grep "Terminating" | cut -d" " -f1)
    do
     echo "deleting namespace $i"
     kubectl get namespace $i -o json |jq '.spec = {"finalizers":[]}' > tempfile.json
     kubectl replace --raw "/api/v1/namespaces/${i}/finalize" -f ./tempfile.json
    done
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search