In this post, we will show you how to use Kubectl command to force delete namespace stuck in terminating state for a long time. You may be seeing this issue when pods are in terminating state for a long time, but there wont be no response. It could be for various reason, like some resources might have gone to nonresponsive mode.
DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
Table of Contents
Understanding Terminating State in Kubernetes
Checking Namespace Status
Identifing Root Cause
Force Deleting Namespace
Understanding Terminating State in Kubernetes:
Checking Namespace Status:
First, we need to check the kubernetes namespace status. Use kubectl get ns command as below.kubectl get namespaces
or
kubectl get ns
Above kubectl get ns command will show you all the list of kubernetes namespace available in your kubernetes cluster. Find your problematic namespace that is in terminating state.
Identifying Root Cause:
Next step is to identify the root cause of kubernetes namespace, why it is entered into terminating state. Use kubectl describe command to get the complete details about the namespace.kubectl describe namespace <namespace-name>
Above kubectl describe command will provide you the complete information about your namespace, in kubernetes. This will include specifications and events. So identify any errors or finalizers that might be causing the termination to hang state.
Force Deleting Namespace:
kubectl delete namespace <namespace-name> --grace-period=0 --force
Where, replace <namespace-name>
with your problematic namespace name. This command will completely remove your namespace from the kubernetes clsuter gracefully.
That's it for this post. Keep practicing and have fun. Leave your comments if any.
Related Searches and Questions asked:
0 Comments