kube-capacity icon indicating copy to clipboard operation
kube-capacity copied to clipboard

Requests calculation method with respect to pod states

Open bortek opened this issue 1 year ago • 0 comments

Hi

I am wondering how the CPU/Mem requests are calculated with respect to the state of the pods? Ideally I want to see the numbers of the Running pods and not all of the others like Completed, Error, ImagePullErr etc.

My total numbers differ a little (607 cores versus 657 cores) if I compare the following metrics query (towards the openshift cluster ) with the output of kube-capacity like this. compute-XX is what the worker nodes are called. Master nodes and other like infra nodes are not included in the counting.

sum(sum(kube_pod_container_resource_requests{node=~"compute.*",resource="cpu"}) by (namespace, pod, node) * on (namespace,pod) group_left() (sum(kube_pod_status_phase{phase="Running"}) by (pod, namespace,node) == 1))

image

kube-capacity --node-labels node-role.kubernetes.io/worker NODE CPU REQUESTS CPU LIMITS MEMORY REQUESTS MEMORY LIMITS * 657424m (87%) 3156928m (421%) 2147320Mi (36%) 5018953Mi (86%)

bortek avatar Feb 14 '24 14:02 bortek