Before doing any other work related to kube-state-metrics, let's evaluate it first.
Why are we looking at kube-state-metrics?
-
The current metrics kube_pod_resource_request emitted by kube-scheduler does not reliably capture short lived pods (less than 30 seconds).
-
Since we rely on the timestamps in our query output to determine start and end time of pods, when we collect metrics at 1 minute interval, the shortest time we can bill for 1 is minute. It's possible to to capture metrics at 30 seconds but then it uses even more data.
Pros of kube-state-metrics
- Captures all pods - including short lived pods.
- Gives us an actual start time timestamp.
- Give us pod UIDs (currently kube-scheduler metrics only use the pod name as a unique identifier).
Cons of kube-state-metrics
No effective pod resource request
Resource requests are provided for each container and initcontainer instead of at the pod level.
The Pod's effective request/limit for a resource is the higher of:
- the sum of all app containers request/limit for a resource
- the effective init request/limit for a resource
If we were to use kube-state-metrics for billing:
- We will need to capture resource requests for all containers and initcontainers
- Based on the pod UIDs, calculate the effective resource request for a pod from all the captured containers and initcontainers.
- Get the timestamp for all the containers/initcontainers and get the min/max of the timestamps to get the start/end for the pod.
Getting pod/container end time is unclear
- @computate has looked into this, but it's unclear why there's no straightforward way to get the pod completion time.
Before doing any other work related to kube-state-metrics, let's evaluate it first.
Why are we looking at kube-state-metrics?
The current metrics
kube_pod_resource_requestemitted bykube-schedulerdoes not reliably capture short lived pods (less than 30 seconds).Since we rely on the timestamps in our query output to determine start and end time of pods, when we collect metrics at 1 minute interval, the shortest time we can bill for 1 is minute. It's possible to to capture metrics at 30 seconds but then it uses even more data.
Pros of kube-state-metrics
Cons of kube-state-metrics
No effective pod resource request
Resource requests are provided for each container and initcontainer instead of at the pod level.
The Pod's effective request/limit for a resource is the higher of:
If we were to use kube-state-metrics for billing:
Getting pod/container end time is unclear