Pods can request the resources needed to run their containers.
Pods can request that its container gets scheduled on a machine, that could provide it with a quarter of a CPU and 256 MiB of RAM for example.
We could define the above requirements in a pod's Yaml file as below:
The resources are specific to the containers, not to the pod, because a pod can host different containers with different needs in terms of resources.
The resources requested by a pod are the total of the resources requested by its containers.
The scheduler and the resource requests:
The kubernetes scheduler uses the requests to assign pods to a node that could meet these requirements. The request tells the scheduler about the minimum resources needed by a container.
A pod scheduled on a 1 CPU node with a request of 250m, will use the whole CPUs, and if four replicas of that same pod get scheduled on the same machine, then they will get 250m - a quarter of a CPU - each.
Using Limits - resource limits -:
The resource request tells kubernetes about the minimum amount of resources required by a pod.
We can also define the maximum amount of resources that could be used by a pod, using a resource limit. We can define a limit of 1.5 CPU and 512 MiB of RAM, for example using the below Yaml file:
A container will not be allocated a CPU count beyond the limit of 1.5 cores, and it will not get more than 512 MiB of RAM.