I am using Kubernetes (specifically, I am using Azure Kubernetes Service, if that matters in this case). As far as I understand:
- I can use the preStop hook to execute some code before my pod is terminated.
- The preStop hook will be interrupted if it takes more seconds than what is defined by the terminationGracePeriodSeconds parameter.
- The preStop is executed at least once in any situation in which the pod will be terminated. That is what I understood from this documentation, although I may be making some mistaken assumptions.
I wanted to know: is there any case in which the preStop hook will not be called at all? For instance, if the pod is evicted or some other scenario.
Also: how safe is it to rely on this hook to execute some logic needed to save the state of the pod?
And, finally: I assume this hook will not be executed if the node (in which the pod "lives") crashes. Is that correct?