zalando-incubator / kube-metrics-adapter

General purpose metrics adapter for Kubernetes HPA metrics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing the helm chart into a namespace other than kube-system does not work

tanersener opened this issue · comments

Expected Behavior

Installing kube-metrics-adapter into a namespace other than kube-system must be allowed. Appending --set namespace=<name> to helm install command should be enough to change the namespace kube-metrics-adapter is installed.

Actual Behavior

When --set namespace=my-app-namespace is added to helm install/upgrade command, kube-metrics-adapter is installed into my-app-namespace as expected. However, HPA rules can not run prometheus queries because of a permission error.

kubectl describe hpa shows the following error for those HPA rules.

unable to fetch metrics from external metrics API: prometheus-query.external.metrics.k8s.io is forbidden: User "system:serviceaccount:kube-system:horizontal-pod-autoscaler" cannot list resource "prometheus-query" in API group "external.metrics.k8s.io" in the namespace "my-app-namespace"

Steps to Reproduce the Problem

  1. Install kube-metrics-adapter helm chart using the following command.
    helm install kube-metrics-adapter docs/helm --namespace=my-app-namespace --set namespace=my-app-namespace --set prometheus.server=http://prometheus --set enableCustomMetricsApi=true --set enableExternalMetricsApi=true

  2. Install an HPA rule which uses a prometheus query to measure an external metric.

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
 name: hpa-rule
 namespace: my-app-namespace
 annotations:
   metric-config.external.prometheus-query.prometheus/hpa-query-1: |
   <MY PROMETHEUS QUERY>
  1. Check events for that HPA rule.

kubectl describe hpa-rule -n my-app-namespace

Specifications

  • Version: 0.1.9
  • Platform: Kubernetes 1.18.x
  • Subsystem: Kind