Graceful shutdown of tomcat on a kubernetes cluster Graceful shutdown of tomcat on a kubernetes cluster kubernetes kubernetes

Graceful shutdown of tomcat on a kubernetes cluster


found the issue:

I was running this prestop lifecycle hook:

lifecycle: preStop: exec: command: ["/usr/local/tomcat/bin/catalina.sh"]

It should be something like:

lifecycle: preStop: exec: command: ["/usr/local/tomcat/bin/catalina.sh && sleep 30"]

In the first case, K8s was attempting to exit out of the lifecycle hook as soon as it invokes the shutdown.sh without waiting for tomcat to drain all threads.

it just takes about 5-10 secs depending upon your app. giving a sleep of 30 secs will keep the prestop hook active which should give enough time for tomcat to finish the shutdown process" .