Kubernetes top (kubectl top) command shows different memory usage than Linux top command ran inside pod.
I’ve created k8s deployment where YAML contains these memory limits:
resources:
limits:
cpu: "1"
memory: 2500Mi
requests:
cpu: 200m
memory: 2Gi
Following commands have output as shown:
bash4.4$ kubectl top pod PODNAME
NAME CPU(cores) MEMORY(bytes)
openam-d975d46ff-rnp6h 2m 1205Mi
Run linux top command:
Kubectl exec -it PODNAME top
Mem: 12507456K used, 4377612K free, 157524K shrd,
187812K buff, 3487744K cached
Note ‘free -g’ also shows 11Gb used.
Issue is this contradicts "kubectl top" which shows only 1205 mb used.