How does kubelet inform about SIGTERM signal to kubernetes node?

Viewed 2093

We have container per pod. Each container runs a service that listens on SIGTERM signal to initiate it's shutdown process.

To initiate the shutdown process,

  1. does kubectl delete pod [podname] command needs to be initiated?

  2. does container receive the SIGTERM signal from the linux kernel of the kubernetes node?

  3. if yes, how does kubelet inform the kernel of kubernetes node, to throw SIGTERM signal on a specific container?

Note: of course pod is just a network namespace isolated container

1 Answers

When initiating a pod deletion request

kubectl delete pods <POD>

the container runtime would send a TERM signal to the main process in each container.

When the --force --grace-period=0 switch options are used, the container runtime will send a TERM followed directly by the KILL signal.

kubectl won't initiate a termination request in a container based fashion but would rather terminate all containers running inside a terminated pod.

Note that a pod won't transition to a TERMINATING state only upon an explicit request to delete the latter, but this should be a core part of how Kubernetes would manage your cluster meaning that it might terminate a perfectly healthy container for one of below reasons:

  • If the deployment is updated with a rolling update
  • If a node is drained
  • If a node runs out of resources

You can check the Pods Lifecycle documentation for further details.

Related