How to test deletionGracePeriodSeconds in pod templates with K8S
I assume you are asking about terminationGracePeriodSeconds
, please correct me if I'm mistaken and I'll edit accrodingly.
The terminationGracePeriodSeconds
is the time between Kubernetes sends the SIGTERM
signal to the pod main process (PID 1
) until it sends the SIGKILL
signal, which abruptly kills the process (and subsequently, the pod itself).
SIGTERM
signal is meant to be interpreted by the process, and it should start a "Graceful Shutdown" - stop receiving new tasks and finish the work on existing ones. If the process in your pod needs more than 30 seconds for this procedure (let's say you're running a worker which process each task in 2 minutes), you'd want to extend the terminationGracePeriodSeconds
accordingly.
So you can't make the pod "reject" the deletion, but your process can either ignore the SIGTERM
signal, and then after the period configured in terminationGracePeriodSeconds
it'll be killed abruptly, or it may be that your process needs more time to gracefully shutdown (and in that case, you'd want to increase `