<p>If I use -XX:MaxRAMPercentage for Java running in a container, and in the K8S definition I provide request and limit values for the container's memory, what will happen?</p>
<p>For example, if the request is 1GB and the limit 2GB, what will be the initial value for the JVM's max memory?</p>

<p>The memory limit applies to the cgroup. So assuming you are using a JVM version 10+, where +UseContainerSupport is enabled by default, your JVMs max memory will be the configured percentage of the limit, i.e. if -XX:MaxRAMPercentage has a value of 100 then your max memory will be 2GB.</p>
<p>Memory request is only used for scheduling of new pods. I.e. Kuberentes won't schedule a pod on a node that has less than the requested memory available.</p>
<p>Reference:</p>
<p><a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-limits-are-run" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-limits-are-run</a></p>
