I'm working with Docker and Kubernetes on AWS (cloudformation yaml)
Yaml
...
resources:
requests:
memory: "4Gi"
cpu: "0.5"
limits:
memory: "4Gi"
cpu: "0.5"
Dockerfile
FROM amazonlinux:latest
RUN yum -y install java-1.8.0
EXPOSE 8103
ADD myapp.jar
ENTRYPOINT ["java","-XX:MinRAMPercentage=50.0","-XX:MaxRAMPercentage=80.0","-jar","myapp.jar"]
Follow you can find the version of java "1.8.0_282" from the bash of my pod
bash-4.2# java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
intx CompilerThreadStackSize = 0 {pd product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx HeapSizePerGCThread = 87241520 {product}
uintx InitialHeapSize := 67108864 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 1073741824 {product}
intx ThreadStackSize = 1024 {pd product}
intx VMThreadStackSize = 1024 {pd product}
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
I read this blog where the author has explained that "If you are running Java 8 update 191 or later, or Java 10, 11,12, 13 etc. you must NOT use the UseCGroupMemoryLimitForHeap option. Instead you should use the UseContainerSupport that is activated by default."
For this reason I have added the options "-XX:MinRAMPercentage=50.0","-XX:MaxRAMPercentage=80.0" in my ENTRYPOINT instruction.
ENTRYPOINT ["java","-XX:MinRAMPercentage=50.0","-XX:MaxRAMPercentage=80.0","-jar","myapp.jar"]
Unfortunately the UseContainerSupport values didn't change on my pod as you can see follow
bash-4.2# java -XX:+PrintFlagsFinal -version | grep -E "UseContainerSupport | InitialRAMPercentage | MaxRAMPercentage | MinRAMPercentage"
double InitialRAMPercentage = 1.562500 {product}
double MaxRAMPercentage = 25.000000 {product}
double MinRAMPercentage = 50.000000 {product}
bool UseContainerSupport = true {product}
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
I have also tried to add JAVA_OPTS in my YAML as following but nothing change
env:
- name: JAVA_OPTS
value: "-XX:MinRAMPercentage=50.0 -XX:MaxRAMPercentage=80.0"
Finally the question :-)
How and where have I to set the -XX:MinRAMPercentage and -XX:MaxRAMPercentage options in order to modify the default value of MaxRAMPercentage? I want use 3Gi of memory of 4Gi dedicated (on yaml)
Thanks to everyone