GoogleCloudPlatform / GoogleCloudPlatform/k8s-stackdriver
k8s_container support for custom-metrics-stackdriver-adapter
- Dominant language
- Go
- Stars
- 409
- Forks
- 236
- Avg merge
- 2h 34m
- Merged PRs (30d)
- 9
Description
Currently the stackdriver adapter supports custom metrics that are reported against k8s_pod or k8s_node in the new resource model. It would be good if we can extend support for k8s_container. We have a lot of metrics that are reported under this schema and we would like to have custom metrics for HPA on those.
As k8s_container labels are a superset of k8s_pod, we can aggregate the metrics on pod level inside the adapter and report it to HPA. The issue here is container is not a kubernetes resource(#145). So we have to map it to a kubernetes resource through a configmap. Validation of this mapping is also required. Ex: k8s_container can map to pods resource, k8s_cluster can't(does not have pod name etc). Is this kind of validation possible?
We can query the metrics based on all tuple of the (kubernetes resource, Monitored Resource Types) mapping stored in configmap. After getting the metrics we can do the validation of mapping(It would be good if we can do it prior to querying but I am not sure about the feasibility of that) and filter out invalid metrics (attached to monitored resource that cannot be mapped to kubernetes resource). We can then aggregate metrics the filtered metrics.
Question: What happens when multiple Monitored Resource Types maps to a single kuberenetes resource? One way could be that we query for all resource type and then filter them maybe based on priority of resource type. ex if both k8s_pod and k8s_container maps to pods resource, we will prefer a metric under k8s_pod compared to k8s_container.
This solution seems complex, Is there any better way to resolve this?
Contributor guide
Assessment
This issue has not been assessed yet.