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?
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.