What happens when a pod resource limit is not exceeded but a single container resource limit is?

Viewed 611

I am searching for an specific information regarding kubernetes requests and limits and still didn't find an answer or just didn't understand quite well. Say I've defined two containers A and B for a single pod, both with its resources limits and requests:

A: RAM request: 1Gi RAM limit: 2Gi B: RAM request: 1Gi RAM limit: 2Gi

So, we have a PoD limit of 4Gi (total). Suppose the A container exceeded the limit (say +1Gi), but B is consuming 64Mi only. So, my questions are:

  1. What happens to the pod? Is it evicted?
  2. Is the container A restarted?
  3. Is the container A allowed to use the B's available RAM?

Thanks!

2 Answers

What happens to the pod? Is it evicted?

If the memory limit of a container is exceeded, the kernel's OOM killer is invoked and terminates the container's process. The Pod then starts a new container on the same Node.

(CPU limits use a different mechanism (CFS Bandwidth Control) that throttles the processes' CPU cycles instead of terminating the process.)

Is the container A restarted?

Yes.

Is the container A allowed to use the B's available RAM?

The memory is tracked separately for each container. They are not pooled together into the same limit.

Just to add some details

Memory request: Is the memory reserved for container, whether it is used completely or not.

Memory Limit: Is a restriction limit of max memory this container is supposed to use. So when containers memory requests exceeds, then whether to allocate or not depends on the free memory available in the machine running that container at that point of time

To answer your queries, from my understanding:

  • If Container A reaches its Memory limit of 2GI, it OOMed and this will restart the containers.

  • If Container A exceeds its Memory request of 1GI, it tries to get the required memory from whats available of the machine(max to what limit is set)

Hope this answers you queries

Related