A few days ago I was assigned a user story to investigate the upgrade of our application in Kubernetes environment without breaking the application servicing customers. One key point in this story is to find out how the Kubernetes pods terminates. After searching using google, I find a good post about pod termination. The main events occurred during the pod termination are as below:
1. Set the state of the pod to ‘terminating’.
2. Move the pod from the endpoints of the services.
3. The preStop hook of the pod is executed.
4. The SIGTERM signal is sent to the pod.
5. Kubernetes waits for a graceful period of time.
6. The SIGKILL signal is sent to the pod
7. The pod is removed from the Kubernetes.