<p>I'm trying to pass the JVM settings to a Java application which is configured to use JKube Maven plugin to deploy on Openshift. I've added in deployment.yaml file the following settings:</p>
<pre><code>spec:
  template:
    spec:
      containers:
      - env:
        - name: JAVA_OPTS
          value: '-Xms128m -Xmx1024m -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256m'
</code></pre>
<p>When the Java process is started in a Pod, I can see that Java_OPTS are overwritten by the default values (see the second setting for <strong>-XX:MaxMetaspaceSize</strong>):</p>
<pre><code>DEBUG [org.jboss.as.config] (MSC service thread 1-1) VM Arguments: -Xms128m -Xmx1024m -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256m -XX:+UseParallelOldGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:+ExitOnOutOfMemoryError 
</code></pre>
<p>That eventually results in:</p>
<pre><code>Terminating due to java.lang.OutOfMemoryError: Metaspace
</code></pre>
<p>Can you recommend a way to set correctly the JVM settings when using JKube Maven plugin?
Thanks</p>

Carla
<p>You have to use the GC_MAX_METASPACE_SIZE environment variable to define the maximum size of the Metaspace. For example:</p>
<pre><code>- name: GC_MAX_METASPACE_SIZE
  value: 256
</code></pre>
<p>Specifically, there's an example here: <a href="http://www.mastertheboss.com/other/java-stuff/solving-java-lang-outofmemoryerror-metaspace-error" rel="nofollow noreferrer">how to set the METASPACE size on Kubernetes/OpenShift</a> using JKube</p>
