HPA using Kafka Exporter in on premise Kubernetes cluster

喜欢而已 提交于 2019-12-11 05:54:22

问题


I had been trying to implement Kubernetes HPA using Metrics from Kafka-exporter. Hpa supports Prometheus, so we tried writing the metrics to prometheus instance. From there, we are unclear on the steps to do. Is there an article where it will explain in details ?

I followed https://medium.com/google-cloud/kubernetes-hpa-autoscaling-with-kafka-metrics-88a671497f07

for same in GCP and we used stack driver, and the implementation worked like a charm. But, we are struggling in on-premise setup, as stack driver needs to be replaced by Prometheus


回答1:


In order to scale based on custom metrics, Kubernetes needs to query an API for metrics to check for those metrics. That API needs to implement the custom metrics interface.

So for Prometheus, you need to setup an API that exposes Prometheus metrics through the custom metrics API. Luckily, there already is an adapter.




回答2:


When I implemented Kubernetes HPA using Metrics from Kafka-exporter I had a few setbacks which I solved doing the following:

  1. I deployed the kafka-exporter container as a sidecar to the pods I wanted to scale. I found that the HPA scales the pod it gets the metrics from.
  2. I used annotations to make Prometheus scrape the metrics from the pods with exporter.

  3. Then I verified that the kafka-exporter metrics are getting to Prometheus. If it's not there you can't advance further.

  4. I deployed prometheus adapter using its helm chart. The adapter will "translate" Prometheus's metrics into custom Metrics Api, which will make it visible to HPA.
  5. I made sure that the metrics are visible in k8s by executing kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 from one of the master nodes.
  6. I created an hpa with the matching metric name.

Here is a complete guide explaining how to implement Kubernetes HPA using Metrics from Kafka-exporter

Please comment if you have more questions



来源:https://stackoverflow.com/questions/57361180/hpa-using-kafka-exporter-in-on-premise-kubernetes-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!