Hey, today a quick post on a bug that sometimes happens in kubernetes while removing pods. If someone is unlucky, when removing the kubernetes, they can “get stuck” in the Terminating state and hang like that for a few days.
Kubectl delete pods --all -n NAMESPACE_NAME Kubectl delete pods POD_NAME -n NAMESPACE_NAME Kubectl delete deployments DEPLOYMENT_NAME -n NAMESPACE_NAME
Manual removal of pod from namespace will not help, even if we specify that we want to delete a specific pod and give its exact name. Removing the ‘deployment’ will also do nothing. POD on kubernetes will be stubbornly stuck in the state of ‘Terminating’.
If we want to fix this, we have to use some force. The command given below always helps me, it removes it almost immediately. Of course, if you have a POD in a dedicated namespace, add its name to the command.
kubectl delete pod POD_NAME --grace-period=0 --force kubectl delete pod POD_NAME --grace-period=0 --force -n NAMESPACE_NAME
There is one more solution, a bit more drastic, that I didn’t have to use. If forcibly removing the pod doesn’t work, you can restart the entire ‘worker’.
You can find more information about Pods and Kubernetes in the documentation on the website https://kubernetes.io/docs/concepts/workloads/pods/pod/