Telco

 View Only
Expand all | Collapse all

Delete namespace in TCA Kubernetes cluster stuck in a terminating state?

Achintya Jain

Achintya JainNov 17, 2022 04:54 PM

  • 1.  Delete namespace in TCA Kubernetes cluster stuck in a terminating state?

    Broadcom Employee
    Posted Nov 17, 2022 04:54 PM


  • 2.  RE: Delete namespace in TCA Kubernetes cluster stuck in a terminating state?
    Best Answer

    Broadcom Employee
    Posted Mar 09, 2023 10:39 PM

    To achieve the desired result in a Tanzu Kubernetes Cluster, use the below command without alterations, it should function properly. I have used it to delete the namespace which was stuck in termination state from 2 days.

     

    NS=`kubectl get ns |grep Terminating | awk 'NR==1 {print $1}'` && kubectl get namespace "$NS" -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/$NS/finalize -f -

     

    This script removes the finalizers in the problematic namespace and removes first terminating namespace in your list. Eg. if you have 3 namespace by terminating status in the environment then you should run this command 3 times.