Issue
Actually I'm using the jib-maven-plugin to create Docker container for my application. Then I'm going to deploy it to Google servers where we have a Kubernetes environment.
Actually we are playing with the java env. variables from the jib-maven-plugin's config (pom.xml):
<jvmFlags>
<jvmFlag>-XX:MinRAMPercentage=60.0</jvmFlag>
<jvmFlag>-XX:MaxRAMPercentage=80.0</jvmFlag>
<jvmFlag>-XX:+HeapDumpOnOutOfMemoryError</jvmFlag>
<jvmFlag>-Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"</jvmFlag>
</jvmFlags>
Now we would like to move these configurations to our deployment yml file, we found something like:
env:
- name: JAVA_OPTS
value: "-XX:MinRAMPercentage=60.0 -XX:MaxRAMPercentage=90.0 -XX:+HeapDumpOnOutOfMemoryError"
...
resources:
limits:
memory: 512Mi
requests:
memory: 256Mi
but it seems that if we remove these configs from the jib-maven-plugin's config file and move them to the yml file they are simply not working. The container starts without having any effects of the mentioned settings.
We are using open JDK 11, that may be also important.
How it's possible to control the Java env. options from the deployment file?
Thank you so much for your help, have a nice day!
Solution
The problem is that you're setting JAVA_OPTS
and not JDK_JAVA_OPTIONS
.
JAVA_OPTS
is used by some application servers like Tomcat, but the JDK itself uses JDK_JAVA_OPTIONS.
Therefore, a working Kubernetes yaml would be something like:
apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
template:
metadata:
...
spec:
containers:
- name: ...
image: ...
env:
- name: JDK_JAVA_OPTIONS
value: -XX:MinRAMPercentage=60 -XX:MaxRAMPercentage=80 -XX:+HeapDumpOnOutOfMemoryError -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"
Answered By - Malt
Answer Checked By - Timothy Miller (JavaFixing Admin)