Is there a way to call a function before the Pod is being terminated? preStop hook examples are based on yaml specs.
I want to use the K8s API, should I just write a SIGTERM handler ? What is the "safe" way to do it ?
Please, checkout finalizers.
They exactly get invoked before getting terminated.
example: https://book.kubebuilder.io/reference/using-finalizers.html?highlight=finalizers#using-finalizers