Logo

Armand.nz

Home / About / Linkedin / Github

Dealing with a Kubernetes Namespace that is stuck in STATUS Terminating

#kubernetes |

Terminating a Kubernetes namespace can sometimes become a cumbersome task when it gets stuck in the “Terminating” status. This issue can arise due to lingering resources that the namespace controller is unable to clean up. Here are the steps to resolve a namespace that is stuck in the terminating state.

Understanding the Problem

When a namespace is deleted, Kubernetes attempts to delete all resources within it. If any resources are not deleted properly, the namespace remains in the “Terminating” state. Common culprits include:

Steps to Resolve

  1. Identify the Stuck Namespace: Use kubectl get namespaces to list all namespaces and identify the one stuck in the “Terminating” status.

  2. Here is a beauty of a command I found in stackoverflow that works a charm

export NAMESPACE="argocd"
# Then run below command to delete the Terminating namespace

kubectl get namespace $NAMESPACE -o json   | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/"   | kubectl replace --raw /api/v1/namespaces/$NAMESPACE/finalize -f -
comments powered byDisqus

Copyright © Armand