Before we start discussing how kubernetes uses control signals to control containers,
Maybe you need to review the start and stop of the container in the control signal part of docker
When kubernetes decides to close a container,
Whether the pod needs to be closed or the container is restarted due to the failure of the survival probe,
Kubernetes sends a SIGTERM signal to the container.
The container is obliged to respond to the SIGTERM signal as soon as possible and terminate it quickly, such as closing the open database connection, cleaning up temporary files, etc
Kubernetes will provide a default grace period of 30 seconds. If the container does not close after 30 seconds, it will send a sigkill signal to kill the container
The default 30 seconds can be modified through the following properties of pod
.spec.terminationGracePeriodSeconds
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: default
spec:
containers:
- name: nginx
image: nginx
terminationGracePeriodSeconds: 30
Note that this attribute is used on POD, not container