Resource Requirements and Limits
Describe about Resource Requirements and Limits
When creating the Pod, it will consume two types of resources on the Node
.
CPU
Memory
If every node lacks sufficient CPU or memory to create a new Pod, an error indicating Insufficient CPU
will occur and The Pod
is in a pending state.
Resource Request
Resource Request
is define to specify amount of CPU and Memory that required for a Pod when creating one. So when the scheduler tries to place the pod on Node
, It uses these numbers to identify a node which has sufficient amount of resource available.
Resource Limit
Resource Limit
is a set of limit for the resource usage on the pod. In the case that the Pod consume resource exceed limit
for CPU It can't over limit but forr Memory It will error Out of memory (OOM)
and terminate Pod .
Noted:
By default the Resource Request
and Resource Limit
does not specify so the pod can consume resource as much as it require .
Resource CPU Unit
0.1 = 100 M (M = Mili) (Minimum required for CPU is 1 M)
1 count = 1 vCPU (AWS) | 1 GCP Core | 1 Azure Core | 1 Hyperthread
Resource Memory Unit
1 G (Gigabyte) = 1,000,000,000 bytes
1 M (Megabyte) = 1,000,000 bytes
1 K (Kilobyte) = 1,000 bytes
1 Gi (Gibibyte) = 1,073,741,824 bytes
1 Mi (Mebibyte) = 1,048,576 bytes
1 K i(Kibibyte) = 1,024 bytes
Behavior CPU and Memory
Case 1 This case If we Pod A consume all resource of Node Pod B is not able to create
Case 2
If we specify only limit
, Kubernetes will set the resource request
automatically the same as limit
Case 3
If we specify both request
and limit
from the picture If the resource request for Pod A is 2 and for Pod B is 1, and both have a limit set to 3, Pod B will retain the resources as it currently utilizes only 1. However, if Pod A intends to consume additional resources, it cannot utilize the remaining resources from Pod B due to the set limit of 3.
Case 4 (Best Practice)
In this scenario, setting only the request ensures that the Pod can be created with a guaranteed amount of resources. Subsequently, if the Pod requires additional resources, it can continue to consume them, as no explicit limit has been set. (If the memory resources in Pod B are insufficient, it necessitates terminating Pod A.)
Last updated