0

Kubernetes use TERM signal on count down replicaSet .
this is so dangerous for my application .
I use Tomcat application server and this application server has own shutdown mechanism for terminating application server.
when i send operating system (Linux) signals (9,15,...) to jvm , JVM does not know what do with threads inside jvm , so threads killed before successfully completed.

Request -----> BackEnd API -----> [Process] -----> Response
                                      ^   
                   Send TERM (Signal) while thread doing Process

Is there any way to change kubernetes container shutdown mechanism ?
I want kubernetes use :

catalina.sh stop
1

A way to do this would be with dumb-init.

Building containers, dumb-init is usually a good practice, dealing with zombies among others. In your case, it would also allow to re-map signals.

In your Dockerfile, you would have something like

CMD ["dumb-init", "--rewrite", "15:28", "/app/start.sh"]

Check with kill -l, SIGINT should be number 15.

Then, in your start script, you may trap the SIGWINCH (28) signal:

#!/bin/sh

trap "cd /app ; catalina.sh stop" SIGWINCH

[your startup script]
exec $JAVA_HOME/bin/java ...
2
  • I can not understand ! Why SIGWINCH signal ?!!!! – mah454 Jan 31 at 7:22
  • pick any signal you can catch. – SYN Jan 31 at 10:07
0

Kubernetes lifecycle is good solution for problems like this :
Container Lifecycle Hooks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.