Back to Charts

Prometheus Adapter

stable/prometheus-adapter/README.md

latest11.0 KB
Original Source

Prometheus Adapter

DEPRECATED and moved to https://github.com/prometheus-community/helm-charts

Installs the Prometheus Adapter for the Custom Metrics API. Custom metrics are used in Kubernetes by Horizontal Pod Autoscalers to scale workloads based upon your own metric pulled from an external metrics provider like Prometheus. This chart complements the metrics-server chart that provides resource only metrics.

Prerequisites

Kubernetes 1.14+

Installing the Chart

To install the chart with the release name my-release:

console
$ helm install --name my-release stable/prometheus-adapter

This command deploys the prometheus adapter with the default configuration. The configuration section lists the parameters that can be configured during installation.

Using the Chart

To use the chart, ensure the prometheus.url and prometheus.port are configured with the correct Prometheus service endpoint. If Prometheus is exposed under HTTPS the host's CA Bundle must be exposed to the container using extraVolumes and extraVolumeMounts.

Additionally, the chart comes with a set of default rules out of the box but they may pull in too many metrics or not map them correctly for your needs. Therefore, it is recommended to populate rules.custom with a list of rules (see the config document for the proper format).

Finally, to configure your Horizontal Pod Autoscaler to use the custom metric, see the custom metrics section of the HPA walkthrough.

The Prometheus Adapter can serve three different metrics APIs:

Custom Metrics

Enabling this option will cause custom metrics to be served at /apis/custom.metrics.k8s.io/v1beta1. Enabled by default when rules.default is true, but can be customized by populating rules.custom:

rules:
  custom:
  - seriesQuery: '{__name__=~"^some_metric_count$"}'
    resources:
      template: <<.Resource>>
    name:
      matches: ""
      as: "my_custom_metric"
    metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)

External Metrics

Enabling this option will cause external metrics to be served at /apis/external.metrics.k8s.io/v1beta1. Can be enabled by populating rules.external:

rules:
  external:
  - seriesQuery: '{__name__=~"^some_metric_count$"}'
    resources:
      template: <<.Resource>>
    name:
      matches: ""
      as: "my_external_metric"
    metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)

Resource Metrics

Enabling this option will cause resource metrics to be served at /apis/metrics.k8s.io/v1beta1. Resource metrics will allow pod CPU and Memory metrics to be used in Horizontal Pod Autoscalers as well as the kubectl top command. Can be enabled by populating rules.resource:

rules:
  resource:
    cpu:
      containerQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>}[3m])) by (<<.GroupBy>>)
      nodeQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>, id='/'}[3m])) by (<<.GroupBy>>)
      resources:
        overrides:
          instance:
            resource: node
          namespace:
            resource: namespace
          pod:
            resource: pod
      containerLabel: container
    memory:
      containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
      nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)
      resources:
        overrides:
          instance:
            resource: node
          namespace:
            resource: namespace
          pod:
            resource: pod
      containerLabel: container
    window: 3m

NOTE: Setting a value for rules.resource will also deploy the resource metrics API service, providing the same functionality as metrics-server. As such it is not possible to deploy them both in the same cluster.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

console
$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

The following table lists the configurable parameters of the Prometheus Adapter chart and their default values.

ParameterDescriptionDefault
affinityNode affinity{}
image.repositoryImage repositorydirectxman12/k8s-prometheus-adapter-amd64
image.tagImage tagv0.7.0
image.pullPolicyImage pull policyIfNotPresent
image.pullSecretsImage pull secrets{}
logLevelLog level4
listenPortPort that application would listen on in the container6443
metricsRelistIntervalInterval at which to re-list the set of all available metrics from Prometheus1m
nodeSelectorNode labels for pod assignment{}
podLabelsLabels to add to the pod{}
podAnnotationsAnnotations to add to the pod{}
priorityClassNamePod priority``
prometheus.urlUrl of where we can find the Prometheus servicehttp://prometheus.default.svc
prometheus.portPort of where we can find the Prometheus service, zero to omit this option9090
prometheus.pathCustom path to append to the prometheus URL``
rbac.createIf true, create & use RBAC resourcestrue
resourcesCPU/Memory resource requests/limits{}
rules.defaultIf true, enable a set of default rules in the configmaptrue
rules.customA list of custom configmap rules[]
rules.existingThe name of an existing configMap with rules. Overrides default, custom and external.``
rules.externalA list of custom rules for external metrics API[]
rules.resourceresourceRules to set in configmap rules{}
service.annotationsAnnotations to add to the service{}
service.portService port to expose443
service.typeType of service to createClusterIP
serviceAccount.createIf true, create & use Serviceaccounttrue
serviceAccount.nameIf not set and create is true, a name is generated using the fullname template``
tls.enableIf true, use the provided certificates. If false, generate self-signed certsfalse
tls.caPublic CA file that signed the APIService (ignored if tls.enable=false)``
tls.keyPrivate key of the APIService (ignored if tls.enable=false)``
tls.certificatePublic key of the APIService (ignored if tls.enable=false)``
extraVolumeMountsAny extra volumes mounts[]
extraVolumesAny extra volumes[]
tolerationsList of node taints to tolerate[]

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

console
$ helm install --name my-release \
  --set logLevel=1 \
 stable/prometheus-adapter

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

console
$ helm install --name my-release -f values.yaml stable/prometheus-adapter