Resources
Learn how to assign CPU/memory resources to your containerized application.
Last updated
Was this helpful?
Learn how to assign CPU/memory resources to your containerized application.
Last updated
Was this helpful?
This section continues from the previous section - make sure you do the tutorial in sequence.
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 details should have a Requests
section with cpu
value set to 100m
:
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.
When specifying the Memory resource allocation, do not accidentally use m
as the unit. 128m
means 0.128 bytes
.
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:
Memory is not a compressible resource. If the application exceeds the Memory limit, then the container will be killed (OOMKilled
) and restarted.
The default can be updated. See documentation.
See documentation for the units descriptions such as m
, M
, and Mi
.
For Java applications, read the section to make sure you are using a Container-Aware OpenJDK version to avoid unnecessary OOMKilled
errors.