When scale replicas==0, do K8s send SIGTERM?

Hello guys,

I didn’t find this information at K8s doc:

When we are deleting a pod, we have all the lifecycle of delete (one of it’s step is to send SIGTERM to the pod application).

But when we are “faking” the restart, using:

kubectl scale --replicas=0 ...
kubectl scale --replicas=1 ...

Are we receiving the same SIGTERM?

I’m asking because my application doesn’t seems to receive the signal when we are scalling…

Yes, there’s not really a way to bypass that

It should receive SIGTERM and if its taking too long, it will eventually get a SIGKILL. You can adjust the timeout with terminationGracePeriodSeconds.

For a detailed explanation of the process and how to modify it, checkout the Termination of Pods section of the docs.

This SIGTERM and SIGKILL is when we are talking about:

kubectl delete...

But when we are talking about set replicas==0, I don’t think it will be the same, right?

What K8s do behind the wall? He just stop serving?

replicas == 0 scales it down to 0, deleting the running pods.

So, all the prehook stop and so on will be called!?

Hmm… So I’ll need to check why my application is not being gracefully shutdown…

Thanks!

Correct - there’s nothing hidden - “delete pod” happens in both paths.

When we do --replicas=0 that means it will repeat or treat same as delete process?

It will delete the pod. There’s only one delete.

DELETE request ----send----- API server
API server ------set deletionTimestamp ------ Pod
Kubelet ----------observe this settings on-------- Pod
Kubelet started to terminate Pod.
I draw a deletion process arch. can you correct me is it right or may be need more integration added?