I don’t know if you already find your answer or not but let me give you some information that may help.
-
cAdvisor extract many memory-related metrics. We will focus on:
-
container_memory_usage_bytes= value in /sys/fs/cgroup/memory/memory.usage_in_bytes file. (Usage of the memory) -
container_memory_working_set_bytes=container_memory_usage_bytes–total_inactive_file(from /sys/fs/cgroup/memory/memory.stat), this is calculated in cAdvisor and is <=container_memory_usage_bytes -
container_memory_rss=total_rssvalue from /sys/fs/cgroup/memory/memory.stat
-
-
Now you know how those metrics are gathered, you need to know that when you use the
kubectl top podscommand, you get the value ofcontainer_memory_working_set_bytesnotcontainer_memory_usage_bytesmetric.so from your values:
5039Mi “working set fro kubectl command” ~= 5064 “from memory.usage file” – 28 “total_inactive_file from Memory section from docker’s container stats API”
-
It is also worth to mention that when the value of
container_memory_usage_bytesreaches to the limits, your pod will NOT get oom-killed. BUT ifcontainer_memory_working_set_bytesorcontainer_memory_rssreached to the limits, the pod will be killed.