1

Is setting a resource request in a container allocates a resource? Let us say I set a 1 CPU request, will that allocate a 1 CPU to that pod?

Or is resource request just like a threshold or an identifier if that pod with a resource request can be deployed to this instance based on available resources?

1 Answer 1

2

There are separately resource requests and resource limits.

Resource requests are mostly used for scheduling. If you have a node with 8 CPU cores and 32 GB of RAM, Kubernetes won't schedule pods to run on that node that, combined, request more than 8.0 CPU cores and 32 GB memory. (That includes any number of pods that have no resource requests at all.) The one exception is that, if you request some amount of CPU, that gets passed on to Docker and if the system is overloaded, process time is allocated proportional to the requested CPU count. Neither cores nor memory are "reserved" in any meaningful way (you're not guaranteed to run on a single specific core if you request 1 CPU unit).

Resource limits affect the pod's operation. Kubernetes will limit a pod's CPU consumption based on the requested CPU limit, and if it goes over its memory limit, the Linux kernel will kill it (described in extended discussion of the docker run -m option). Remember that pods are scheduled based only on their resource requests, so it's possible to have a collection of pods that together don't request more than available memory but do wind up using too much memory, and in this case the kernel OOM-killer will wind up killing something off too.

Sign up to request clarification or add additional context in comments.

3 Comments

Sorry but you didn't really directly answer the important part. Does resource request allocate a resource? Let's say I set 100M memory resource request, will that allocate 100M memory resource request?
@DeanChristianArmada yes, it will immediately allocate (meaning take from the available count) the requested resource(s) if available.
ok thanks you for giving the specific answer that I am looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.