You can specify the computing resource needs for each of the containers. By default, each container is given 10% of a CPU and no memory use restrictions.
The defaults can cause issues:
If a Node has 1 full CPU, then Kubernetes may schedule up to 10 instances of the same container, which may overload the system.
If a Node has 16GB of RAM, and without memory restriction, then each container instance (JVM) may think they each can use up to 16GB, causing memory overuse (and thus, virtual memory swapping, etc)
You can see the current resource by describing a Pod instance, look for the Requests/Limits lines.
The default value is 100m, which means 100 milli = 100/1000 = 10%of a vCPU core.
The default is configured per Namespace. The application was deployed into the default Namespace. Look at the default resource configuration for this Namespace:
See the output:
However, the configuration is actually stored in a LimitRange Kubernetes resource:
In Kubernetes, you can reserve capacity by setting the Resource Requests to reserve more CPU and memory. Configure the deployment to reserve at least 20% of a CPU, and 128Mi of RAM.
In this example, CPU request is 200m which means 200 milli=200/1000 = 20% of 1 vCPU core.
Memory is 128Mi, which is 128 Mebibytes = ~134 Megabytes.
When specifying the Memory resource allocation, do not accidentally use m as the unit. 128m means 0.128 bytes.
Resource Limit
The application can consume more CPU and memory than requested - it can burst up to the limit, but cannot exceed the limit. Configure the deployment to set the limit:
CPU limit is a compressible resource. If the application exceeds the CPU limit, it'll simply be throttled, and thus capping the latency and throughput.
Memory is not a compressible resource. If the application exceeds the Memory limit, then the container will be killed (OOMKilled) and restarted.
For Java applications, read the Container Awareness section to make sure you are using a Container-Aware OpenJDK version to avoid unnecessary OOMKilled errors.