Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda