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" ]
You could try dumb-init or something similar. The README at the given link elaborates a bit on "Why you need an init system".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With