Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
Java jib-maven-plugin with Kubernetes memory controll

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!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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"
over 4 years ago · Santiago Trujillo Report

0

Just adding a bit to the other answer.

For those using Java 9+ (as with OP), both JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS (beware it's neither JAVA_TOOLS_OPTIONS, JAVA_TOOL_OPTS, nor JAVA_OPTS) will likely work in this use case to prepend options at runtime.

For those using Java 8, only JAVA_TOOL_OPTIONS will work.

over 4 years ago · Santiago Trujillo Report

0

Move your jvm parameters to config map and initialize your pod from it by reading it as an env variables. Here is an example how you can achieve it

https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!