Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

336
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda