This module allows HPA and VPA autoscalers base their decisions on various metrics.

It installs an implementation of the Kubernetes resource metrics API, custom metrics API, and external metrics API to get Prometheus metrics.

As a result:

  • kubectl top can collect Prometheus metrics via the adapter;
  • autoscaling/v2beta2 can be used for scaling applications (HPA);
  • prometheus data can be obtained using the Kubernetes API and utilized in other modules (Vertical Pod Autoscaler, etc.).

The following parameters serve as a basis for scaling:

  • cpu (of the pod),
  • memory (of the pod),
  • rps (of the ingress) - over 1,5,15 minutes (rps_Nm),
  • cpu (of the pod) - over 1,5,15 minutes (cpu_Nm) - average CPU utilization over N minutes,
  • memory (of the pod) - over 1,5,15 minutes (memory_Nm) - average Memory utilization over N minutes,
  • any Prometheus metrics and any queries based on them.

How does it work?

This module registers k8s-prometheus-adapter as an external API service that extends the capabilities of the Kubernetes API. When some Kubernetes component (VPA, HPA) needs information about the resources consumed, it requests the Kubernetes API, which, in turn, proxies that request to the adapter. The adapter figures out (using its configuration file](https://github.com/deckhouse/deckhouse/blob/main/modules/301-prometheus-metrics-adapter/templates/config-map.yaml)) how to calculate the metric and sends a request to Prometheus.