Hi All,
We would like to propose a new metric addition that describes the used resources by pods in every node.
Its name could be
kube_node_current_pod_cpu_requests,
kube_node_requested_cpu_resources,
kube_node_allocated_cpu_resources.
The names extend naturally for memory
Or something else suggested by you we are open to suggestions for names.
As the desired semantics, we propose this metric to contain the sum of requested resources of all the currently running pods in that node.
The same computation is done every time one executes kubectl describe node
.
The resources table is computed every time from scratch.
For example
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
default k8s-master-127.0.0.1 0 (0%) 0 (0%) 0 (0%) 0 (0%)
default k8s-proxy-127.0.0.1 0 (0%) 0 (0%) 0 (0%) 0 (0%)
hello-world-hbaba-build hello-world-hbaba-989929512-6jiaf 800m (20%) 20 (500%) 100Mi (2%) 100Mi (2%)
hello-world-hbaba-build hello-world-hbaba-989929512-8hq9v 800m (20%) 20 (500%) 100Mi (2%) 100Mi (2%)
hello-world-hbaba-build hello-world-hbaba-989929512-jjd5n 800m (20%) 20 (500%) 100Mi (2%) 100Mi (2%)
hello-world-hbaba-build hello-world-hbaba-989929512-n00t2 800m (20%) 20 (500%) 100Mi (2%) 100Mi (2%)
kube-system kube-dns-v10-z4ics 310m (7%) 310m (7%) 170Mi (4%) 170Mi (4%)
Allocated resources:
(Total limits may be over 100%, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md)
CPU Requests CPU Limits Memory Requests Memory Limits
------------ ---------- --------------- -------------
3510m (87%) 80310m (2007%) 570Mi (14%) 570Mi (14%)
The code for that table is in kubernetes/pkg/kubectl/describe.go
file in describeNodeResource
function. It iterates over a collection that is accessed like this :
nodeNonTerminatedPodsList, err := d.Core().Pods(namespace).List(api.ListOptions{FieldSelector: fieldSelector})
For the above example the printed metrics would be
kube_node_current_pod_cpu_requests{node="compute-node01"} 3510
kube_node_current_pod_memory_requests{node="compute-node01"} 80310
Our use case for this metric is the following:
We would like to understand the "utilization" of the nodes and we would like to understand how much resources have been allocated to running pods and how much is left.
We are interested in this "currentPodRequests" information at the node level as well as at the global cluster level.
We have created this issue to get any reactions to this suggestion. Has there been any similar discussions before? Would a PR adding this metric welcomed ?
Another alternative would be to extend the NodeStatus type and add a "currentPodRequests" field in the NodeStatus type in the kubernetes API.
We have also created an issue about that approach in the kubernetes repo. Since that is an API change we cannot anticipate the reaction it is going to get .
We propose that it is valuable to add such a currentPodRequests metric for nodes into kube-state-metrics.
Thanks