Resources
Learn how to assign CPU/memory resources to your containerized application.
This section continues from the previous section - make sure you do the tutorial in sequence.
DeploymentDefault Configuration
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.
You can see the current resource by describing a Pod instance, look for the Requests/Limits lines.
POD_NAME=$(kubectl get pods -lapp=helloworld -o jsonpath='{.items[0].metadata.name}')
kubectl describe pod $POD_NAMEThe details should have a Requests section with cpu value set to 100m:
Name: helloworld-...
Namespace: default...
Containers:
helloworld:
...
Requests:
cpu: 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:
Resource Request
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.
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:
Last updated