<p>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?</p>

<p>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?</p>

Dean Christian Armada
<p>There are separately resource <em>requests</em> and resource <em>limits</em>.</p>

<p>Resource <em>requests</em> are <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-pods-with-resource-requests-are-scheduled" rel="nofollow noreferrer">mostly used for scheduling</a>.  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 <a href="https://docs.docker.com/engine/reference/run/#cpu-share-constraint" rel="nofollow noreferrer">passed on to Docker</a> 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).</p>

<p>Resource <em>limits</em> <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-pods-with-resource-limits-are-run" rel="nofollow noreferrer">affect the pod's operation</a>.  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 <a href="https://docs.docker.com/engine/reference/run/#user-memory-constraints" rel="nofollow noreferrer">extended discussion of the <code>docker run -m</code> option</a>).  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.</p>
