Junior — Middle
What will happen to a Pod container if it requests more resources than allocated in its configuration?
sobes.tech AI
Answer from AI
If a container in a Pod requests more resources than allocated to it (for example, CPU or memory), the behavior depends on the resource type and settings:
-
CPU: Kubernetes uses the scheduler mechanism and cgroups. If a container tries to use more CPU than allocated, it will be throttled, meaning its processes will be given less CPU time, but the container will not be stopped.
-
Memory: If a container exceeds its memory limit, it will be killed by the system (OOMKilled), as memory is a hard limit. After this, Kubernetes may restart the container according to the restart policy.
Thus, exceeding the CPU limit results in slowdown, while exceeding the memory limit leads to stopping and restarting the container.