Is sum of containers equals pod memory usage in kubernetes?

898 views Asked by At

I have two commands

1. kubectl top pod $podName --no-headers

2. kubectl top pod $podName --containers --no-headers

For pod that consist of 1 container only, the memory and cpu usage of the pod and container would be the same.

But however for pod with multiple containers, sometimes the sum of containers' resource usage is not equal pod's resource usage, e.g.

CPU
pod: 2m
container1: 1m
container2: 2m

From kubernetes's official document, 1m is the minimum precision to represent fraction.

For above case, I guest

  1. it may due to quantization of containers' individual resource, e.g. 0.0005cpu will be quantized to 1m cpu
  2. Pod is using non-quantized resource value to calculate pod total

But even so, this is just my guest, and I could not find anywhere in official document explaining whether pod is using non-quantized resource value or not.

Appreciate if anyone could explain with document links to me about the difference between pod resource usage and sum of containers resource usage, and which one is the most accurate one to use?

0

There are 0 answers