Reputation: 186
My aim is to gracefully terminate my REST application Pods. I have 2 pods running and when 1 Pod is deleted, requests should be gracefully migrated to other pods. I am using Minikube (v1.20.0)for testing with Jmeter script running 100 API calls. I have also added a delay of 3 seconds inside my API.
I tried to set value of terminationgraceperiodseconds to 60 but learnt that pod was getting deleted within 30 seconds and there were some failures in my jemeter test requests.
I tried reducing value of terminationgraceperiodseconds to 10 seconds and saw that Pod gets deleted within 10 seconds.
Next I read about preStop hook and I added a preStop hook with sleep time as 15 seconds. With this change, my requests started gracefully migrating to other pods even if i deleted the pod which was swerving requests.
I would like to know why parameter terminationgraceperiodseconds whose value set to 60 seconds is taking 30 seconds to terminate the pod. Any other settings I need to change ?
Upvotes: 2
Views: 3891
Reputation: 1928
this is working as expected! when you kill/delete a pod a SIGTERM signal is sent to the pod. kubernetes waits up to "terminationgraceperiodseconds" for the pod to shutdown normally after receiving the SIGTERM.
after terminationgraceperiodseconds has passed and the pod has shutdown itself then kubernetes will send a SIGKILL signal, killing the pod without waiting for it to gracefully shutdown.
so if your pod is terminated after 30 seconds while you have 60 seconds configured for terminationgraceperiodseconds that just means, that the pod shutdown its processes after 30 seconds.
Upvotes: 1