4
votes

I try to get CPU/Memory usage of the k8s Cluster Nodes via metrics-server API, but I found the returned values of metrics-server is lower than actual used CPU/Memory.

The output of kubectl top command : kubectl top nodes

enter image description here

The following is the output of the free command, from which you could see the memory usage is great than 90%.

enter image description here

Why the difference is so high?

2

2 Answers

0
votes

kubectl top nodes is reflecting the actual usage of your Kubernetes Nodes.

For example:

Your node has 60GB memory and you actually use 30GB so it will be 50% of usage.

But you can request for example:

100 MB and have a limit 200MB memory.

This doesn't mean you only consume 0.16% (100 / 60000) memory, but the amount of your configuration.

0
votes

I know this is an old topic, but I think the problem is still remaining.

To answer simply, the kubectl top command shows ONLY the actual resource usage, and it is not related to the request/limits configurations in your manifests.

for example:

you could obtain a 400m:1Gi (cpu/memory) usage for a specifique node while total requests/limits are 1.5:4Gi (cpu/memory).

You will observe enougth available resources to schedule but actually it will not work.

requests/limits are impacting directly node resources (resources reservation) but it does not means they are completly used (what kubectl top nodes is showing).