End of Docker and Kubernetes: Grace period from SIGTERM to SIGKILL

A rough understanding of SIGTERM and SIGKILL

Here's a quick overview of SIGTERM and SIGKILL:

Graceful shutdown

Graceful shutdown means that a process or the like closes the acceptance of new work, processes the work in process to the point where it is in process, and then finishes it safely. The image is "stores".

When a kill occurs, the system may be in a half-finished state or the data may be inconsistent. Graceful shutdown is a protective measure to prevent this from happening.

For example, considering the graceful shutdown of an HTTP server as an example, when the HTTP server enters the termination phase, it will not accept new requests, but the existing requests will be terminated after returning a proper response.

Docker, Kubernetes, etc. should send a SIGTERM signal after sending aSIGTERM signal so that the application can be gracefully shut down, and then after a certain grace period, if it still does not terminate, send a SIGKILL to force it to terminate. It has become.

Grace from SIGTERM to SIGKILL such as Docker and Kubernetes

The grace period depends on the system. The grace period for each system is listed below. Please refer to it when implementing Graceful Shutdown.

docker stop

docker kill

Kubernetes Pod Termination

Systemd

Upstart

Sysvinit

Recommended Posts

End of Docker and Kubernetes: Grace period from SIGTERM to SIGKILL
[Challenge Docker from 0] Overview and terms of Docker
Overview of Docker and containers
Migrating from vargrant to docker
Method to add the number of years and get the end of the month
From fledgling Java (3 years) to Node.js (4 years). And the impression of returning to Java
From introduction to use of ActiveHash
From introduction to usage of byebug
Update MySQL from 5.7 to 8.0 with Docker
Challenge to install WSL2 and docker
Confirmation and refactoring of the flow from request to controller in [httpclient]
[Summary of technical books] Summary of reading "Introduction to Docker / Kubernetes Practical Container Development"
I translated the grammar of R and Java [Updated from time to time]