VMware Communities
jachintya20
VMware Employee
VMware Employee
Jump to solution

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

 
1 Solution

Accepted Solutions
jachintya20
VMware Employee
VMware Employee
Jump to solution

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.

View solution in original post

1 Reply
jachintya20
VMware Employee
VMware Employee
Jump to solution

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.