All pods are notified via SIGTERM that they should shut down. You can also register a pre-stop hook in the pod definition that is given a chance to run before SIGTERM is sent. You must set a longer terminationGracePeriodSeconds if you need more than the default 30s:
$ oc explain pod.spec.terminationGracePeriodSeconds
FIELD: terminationGracePeriodSeconds <integer>
Optional duration in seconds the pod needs to terminate gracefully. May be
decreased in delete request. Value must be non-negative integer. The value
zero indicates delete immediately. If this value is nil, the default grace
period will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination signal and the
time when the processes are forcibly halted with a kill signal. Set this
value longer than the expected cleanup time for your process. Defaults to 30
$ oc explain pod.spec.containers.lifecycle.preStop
RESOURCE: preStop <Object>
PreStop is called immediately before a container is terminated. The
container is terminated after the handler completes. The reason for
termination is passed to the handler. Regardless of the outcome of the
handler, the container is eventually terminated. Other management of the
container blocks until the hook completes. More info: http://
Handler defines a specific action that should be taken
TCPSocket specifies an action involving a TCP port. TCP hooks not yet
One and only one of the following should be specified. Exec specifies the
action to take.
HTTPGet specifies the http request to perform.
Note that "other management of he container blocks until the hook completes" means other actions taken by kube against the pod. The grace period still applies (you will be terminated after that duration).