What is the process of Pod exiting?
This article mainly explains the "Pod exit process is how", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Pod exit process is how" it!
The user deletes the Pod.
2.1. Pod enters the Terminating state.
2.2. At the same time, K8s removes Pod from the corresponding service.
2.3. At the same time, for containers with PreStop Hook, kubelet invokes the PreStop Hook of each container, and if the running time of PreStop Hook exceeds grace period (defined in the .spec.terminationGracePerforming seconds field of Pod), kubelet sends SIGTERM and waits for another 2 seconds.
2.4. At the same time, kubelet sends SIGTERM for containers that do not have PreStop Hook.
After the grace period exceeds, kubelet sends SIGKILL to kill the containers that have not yet exited.
Therefore, there is also a "maximum tolerable time" in the Pod termination process for K8s, namely grace period (defined in the .spec.terminationGracePerforming seconds field of Pod), which defaults to 30 seconds, and we can also override the configuration in Pod by explicitly specifying an elegant exit time when we execute kubectl delete with the-grace-period parameter. When the grace period exceeds, K8s can only choose SIGKILL to force Pod to be killed.
-
K8s version 1.11.2
TerminationGracePeriodSeconds: 300
Lifecycle:
PreStop:
Exec:
Command: ["/ bin/bash", "- c", "sleep 300"]
Set the same effect: 30s
Set different to terminationGracePeriodSeconds > preStop sleep.
Subject to preStop sleep
= those providing services to the outside world
TerminationGracePeriodSeconds = 360
PreStop sleep=300
= of the task task type
TerminationGracePeriodSeconds = 3
PreStop sleep=2
Thank you for your reading, the above is the content of "what is the process of Pod exit". After the study of this article, I believe you have a deeper understanding of how the process of Pod exit is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!