Questão de Service Configuration #019e3a4f
Which tools enable Kubernetes HorizontalPodAutoscalers to use custom, application-generated metrics to trigger scaling events?
Prometheus and the prometheus-adapter.
Graylog and graylog-autoscaler metrics.
Graylog and the kubernetes-adapter.
Grafana and Prometheus.
Explicação Oficial / Explicações da Comunidade
The correct tool combination is Prometheus and the prometheus-adapter. The HorizontalPodAutoscaler (HPA) in Kubernetes can scale pods based on custom metrics, not just CPU/memory. To use application-generated metrics, you need a metrics adapter that implements the custom.metrics.k8s.io API. Prometheus collects metrics from applications, and the prometheus-adapter (also known as k8s-prometheus-adapter) exposes those metrics to the Kubernetes API server, allowing the HPA to query them.
How it works:
- Prometheus scrapes custom metrics from application endpoints (e.g., /metrics).
- The prometheus-adapter is configured with rules to map Prometheus metrics to Kubernetes custom metrics.
- The HPA references these custom metrics in its configuration (e.g.,
type: Objectortype: Podswith a metric name). - The HPA queries the custom.metrics.k8s.io API, which the adapter serves, and scales pods accordingly.
Why the incorrect options are wrong:
- Graylog is a log management system, not a metrics collector. It does not provide a metrics API for HPA. The graylog-autoscaler metrics and kubernetes-adapter are not standard Kubernetes components.
- Grafana is a visualization tool; it does not expose metrics to the Kubernetes API. While Prometheus is correct, Grafana alone cannot serve custom metrics to HPA.
Only Prometheus with the prometheus-adapter enables HPA to use custom application metrics for scaling.