cloudworkz / kube-eagle

A prometheus exporter created to provide a better overview of your resource allocation and utilization in a Kubernetes cluster.
MIT License
704 stars 46 forks source link

allocatable vs. capacity #27

Closed MarcMielke closed 5 years ago

MarcMielke commented 5 years ago

Nice work! Very useful. But it looks like for cpu the capacity is reported instead of the allocatable.

weeco commented 5 years ago

Hey @MarcMielke , I checked the code again, but I think I am indeed using the allocatable CPU cores: https://github.com/cloudworkz/kube-eagle/blob/master/collector/node_resources.go#L148

The reported metrics seem to match our allocatable CPU cores as well. Am I missing something?

MarcMielke commented 5 years ago

We use resource allocation management (reserving some cpu for kubeReserved/systemReserved) and what I see - using kubectl describe node - is that if we a have 2 (2000m) cpu node capacity and an 1600m cpu allocatable. But kube-eagle shows 2 as allocatable, not the 1600m which I would expect. Semantics of your code look correct though. There is a corner-case where allocatable equals capacity if not reserving resources via kubeReserved/systemReserved. But we do use it, so sth isn't working correctly. Or is there some rounding-up?

For memory it works correctly. The allocatable value is shown.

weeco commented 5 years ago

As you can see in the shown code above I am using the official Kubernetes client and indeed I call Allocatable() instead of Capacity(). Also for our nodes (GKE) this is reported correctly. Hence I believe this issue might be out of scope here.

MarcMielke commented 5 years ago

wonder wether .MilliValue() - like you do it for memory - would make a difference.