Prometheus Adapter for Kubernetes Metrics APIs: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
* [[Kubernetes_Horizontal_Pod_Autoscaler#Custom_Metrics-based_Scaling|Horizontal Pod Autoscaler]]
* [[Kubernetes_Horizontal_Pod_Autoscaler#Custom_Metrics-based_Scaling|Horizontal Pod Autoscaler]]
=Overview=
=Overview=
The Prometheus adapter is a [[Kubernetes_Aggregation_Layer#Overview|Kubernetes Aggregation Layer]] extension and operates as an [[Kubernetes_Aggregation_Layer#Extension_API_Server|extension API server]]. It knows how to communicate with both Kubernetes and Prometheus, acting as a translator between the two.
The Prometheus adapter is a [[Kubernetes_Aggregation_Layer#Overview|Kubernetes Aggregation Layer]] extension and operates as an [[Kubernetes_Aggregation_Layer#Extension_API_Server|extension API server]]. It knows how to communicate with both Kubernetes and Prometheus, acting as a translator between the two. The API is registered as "custom.metrics.k8s.io/v1beta1"


[[File:Metrics_and_Autoscaling_PrometheusAdapter.png]]
[[File:Metrics_and_Autoscaling_PrometheusAdapter.png]]

Revision as of 04:10, 15 October 2020

External

Internal

Overview

The Prometheus adapter is a Kubernetes Aggregation Layer extension and operates as an extension API server. It knows how to communicate with both Kubernetes and Prometheus, acting as a translator between the two. The API is registered as "custom.metrics.k8s.io/v1beta1"

Metrics and Autoscaling PrometheusAdapter.png

Helm Installation

https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-adapter

Install Prometheus first.

The adapter will be installed in the same namespace as Prometheus.

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm search repo prometheus-community
helm install -n prom prometheus-adapter prometheus-community/prometheus-adapter -f ./prometheus-adapter-overlay.yaml

See Configuration below for prometheus-adapter-overlay.yaml.

Test installation:

kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 | jq
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "custom.metrics.k8s.io/v1beta1",
  "resources": [
    {
      "name": "jobs.batch/kubernetes_build_info",
      "singularName": "",
      "namespaced": true,
      "kind": "MetricValueList",
      "verbs": [
        "get"
      ]
    },
    {
      "name": "services/kube_deployment_spec_strategy_rollingupdate_max_surge",
      "singularName": "",
      "namespaced": true,
      "kind": "MetricValueList",
      "verbs": [
        "get"
      ]
    },
   ...
}

Configuration

Use the following prometheus-adapter-overlay.yaml:

helm show values prometheus-community/prometheus-adapter > ~/tmp/prometheus-adapter-overlay.yaml
prometheus:
  url: http://prometheus-kube-prometheus-prometheus.prom.svc

Increase log level when installing the chart.

Configuration Resources:

Troubleshooting

tail the logs, Prometheus connection refused is reported there.