How do I troubleshoot namespaces in a terminated state in my Amazon EKS cluster?
Last updated: 2021-12-14
I tried to delete a namespace in my Amazon Elastic Kubernetes Service (Amazon EKS) cluster. However, the namespace is stuck in the "Terminating" status.
To delete a namespace, Kubernetes must delete all the resources in the namespace and then check registered API services for the status. If the namespace contains resources that Kubernetes wasn't able to delete, or if an API service has a "False" status, then the namespace is stuck in the "Terminating" status.
Follow these instructions to delete namespaces stuck in the "Terminating" status.
1. Save a JSON file similar to the following:
kubectl get namespace <terminating-namespace> -o json > tempfile.json
2. Edit the JSON file and remove the finalizers from the array.
3. To apply the changes, run a command similar to the following:
kubectl replace --raw "/api/v1/namespaces/<terminating-namespace>/finalize" -f ./tempfile.json
4. Verify that the terminating namespace is removed:
kubectl get namespaces
Repeat these steps for any remaining namespaces stuck in the "Terminating" status.