Advertisement |
You might have faced a situation of "Pods getting stuck on terminating" issue when trying to delete the namespace. This could be irritating especially when you might need the namespace delete results instantly.
No Problem, Kubernetes has provided a way to deal with this situation. We need to force delete the pod providing the pod name and namespace
Force Delete Command➤
< kubectl delete pod "podname" -n "namespace" --grace-period=0 --force >
Now, What if you have 10 to 20 Pods listed in "terminating status" even when you have issued a delete namespace command. So Now, You may need to force delete all of them one by one.
But deleting them manually could be a cumbersome job and needs a lot of patience.
Well, there is a way where you can deal with this situation as well:
Code 1➤ Groovy Code to force delete multiple pods
Code 2➤ Shell Script Code to force delete multiple pods
No Problem, Kubernetes has provided a way to deal with this situation. We need to force delete the pod providing the pod name and namespace
Force Delete Command➤
< kubectl delete pod "podname" -n "namespace" --grace-period=0 --force >
Now, What if you have 10 to 20 Pods listed in "terminating status" even when you have issued a delete namespace command. So Now, You may need to force delete all of them one by one.
But deleting them manually could be a cumbersome job and needs a lot of patience.
Well, there is a way where you can deal with this situation as well:
Code 1➤ Groovy Code to force delete multiple pods
Code 2➤ Shell Script Code to force delete multiple pods
Fixing this issue is complex since Node draining in Kubernetes must be configured in a way to work for your environment. You can use Shoreline debbugging tool. Shoreline’s Pods Stuck in Terminating Op Pack talks to Kubernetes master and checks on various pod states and determines if a pod has been terminating for too long. This is done by cordoning, draining, and then terminating the node so that it is safely cleaned up so that it is not impacting other software.
ReplyDelete