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:
spec:
template:
spec:
containers:
- env:
- name: JAVA_OPTS
value: '-Xms128m -Xmx1024m -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256m'
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 -XX:MaxMetaspaceSize):
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
That eventually results in:
Terminating due to java.lang.OutOfMemoryError: Metaspace
Can you recommend a way to set correctly the JVM settings when using JKube Maven plugin? Thanks
You have to use the GC_MAX_METASPACE_SIZE environment variable to define the maximum size of the Metaspace. For example:
- name: GC_MAX_METASPACE_SIZE
value: 256
Specifically, there's an example here: how to set the METASPACE size on Kubernetes/OpenShift using JKube