preStop
command will kill the container. Basically, it will kill your app process. If you set up only 'preStop', it does not work, unfortunately. Here is a sample POD, I played with minikube to test.
apiVersion: v1
kind: Pod
metadata:
name: lifecycle-demo
spec:
containers:
- name: lifecycle-demo-container
image: nginx
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
preStop:
exec:
command: ["/bin/sh", "-c", "/bin/sleep 120"]
terminationGracePeriodSeconds: 6000
I am telling to hold the kill for 120 second before killing it. If that does not happen, it will violently be killed after 6000 second.
For your case, terminationGracePeriodSeconds
itself should be enough.