Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gracefully shutdown Spring application running in Kubernetes

I've implemented graceful shutdown logic in my Spring application and it works locally if I send a SIGTERM to the Java process.

However when I'm running it in Kubernetes if I delete the pod or deploy a new one, the logic is not running. First I thought that it's sending SIGKILL instead of SIGTERM but as I've researched, the Docker CMD gets the SIGTERM but does not delegate it to the application. How should I run it correctly?

Right now I'm using this command in my Dockerfile:

CMD [ "java", "-jar", "/app.jar" ]
like image 635
OCPi Avatar asked Oct 23 '25 16:10

OCPi


1 Answers

You could try dumb-init or something similar. The README at the given link elaborates a bit on "Why you need an init system".

like image 90
apisim Avatar answered Oct 25 '25 05:10

apisim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!