From b6287efb21dae731185f14618f4ff4c9c48ac618 Mon Sep 17 00:00:00 2001 From: TheRealNoob Date: Mon, 16 Oct 2023 12:05:30 -0500 Subject: [PATCH] [kube-prometheus-stack] add serviceMonitor.additionalEndpoints (#3515) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add serviceMonitor.additionalEndpoints Signed-off-by: TheRealNoob * [prometheus-json-exporter] defaults and service labels/annotations support (#3865) * Fixed defaults for annotations from list to dict Signed-off-by: Aaron Benton Signed-off-by: Aaron Benton * Added service labels and annotations Signed-off-by: Aaron Benton Signed-off-by: Aaron Benton * Added ingress labels Signed-off-by: Aaron Benton Signed-off-by: Aaron Benton * Bumped version to 0.7.2 Signed-off-by: Aaron Benton Signed-off-by: Aaron Benton --------- Signed-off-by: Aaron Benton Signed-off-by: Aaron Benton Signed-off-by: TheRealNoob * fix closing if statements Signed-off-by: TheRealNoob * add newlines Signed-off-by: TheRealNoob * fix root reference Signed-off-by: TheRealNoob * [kube-prometheus-stack] Fix IO panels in Cluster Overview (#3902) Signed-off-by: Jan-Otto Kröpke Signed-off-by: TheRealNoob * [kube-prometheus-stack] fix range function in servicemonitors (#3888) * fix range function to include relabelings and metricRelabelings Signed-off-by: Christian Niehoff * bump chart version Signed-off-by: Christian Niehoff --------- Signed-off-by: Christian Niehoff Signed-off-by: TheRealNoob * [prometheus-smartctl-exporter] Add relabelings to servicemonitor (#3891) * [prometheus-smartctl-exporter] Add relabelings to servicemonitor Signed-off-by: nepomucen * bump chart version to 0.6.1 Signed-off-by: nepomucen * Revert "bump chart version to 0.6.1" This reverts commit 124b85cd2256ee8cb8d416a883ba5b41f57254cc. Signed-off-by: nepomucen * Bump chart's minor version instead of patch version Signed-off-by: nepomucen * Use with to control variable scoping Signed-off-by: nepomucen --------- Signed-off-by: nepomucen Signed-off-by: TheRealNoob * bump chart version Signed-off-by: TheRealNoob --------- Signed-off-by: TheRealNoob Signed-off-by: Aaron Benton Signed-off-by: Aaron Benton Signed-off-by: Jan-Otto Kröpke Signed-off-by: Christian Niehoff Signed-off-by: nepomucen Signed-off-by: TheRealNoob Co-authored-by: Aaron Co-authored-by: Jan-Otto Kröpke Co-authored-by: Christian Niehoff Co-authored-by: Szymon Janczy --- charts/kube-prometheus-stack/Chart.yaml | 2 +- .../alertmanager/servicemonitor.yaml | 57 +++++++++++++------ .../templates/prometheus/servicemonitor.yaml | 57 +++++++++++++------ .../thanos-ruler/servicemonitor.yaml | 41 ++++++++++--- charts/kube-prometheus-stack/values.yaml | 49 +++++++++++++--- 5 files changed, 152 insertions(+), 54 deletions(-) diff --git a/charts/kube-prometheus-stack/Chart.yaml b/charts/kube-prometheus-stack/Chart.yaml index 000c4673b3e2..6dfca8826924 100644 --- a/charts/kube-prometheus-stack/Chart.yaml +++ b/charts/kube-prometheus-stack/Chart.yaml @@ -21,7 +21,7 @@ name: kube-prometheus-stack sources: - https://github.com/prometheus-community/helm-charts - https://github.com/prometheus-operator/kube-prometheus -version: 51.8.1 +version: 51.9.0 appVersion: v0.68.0 kubeVersion: ">=1.19.0-0" home: https://github.com/prometheus-operator/kube-prometheus diff --git a/charts/kube-prometheus-stack/templates/alertmanager/servicemonitor.yaml b/charts/kube-prometheus-stack/templates/alertmanager/servicemonitor.yaml index 8d507ba5e002..564f70466fcf 100644 --- a/charts/kube-prometheus-stack/templates/alertmanager/servicemonitor.yaml +++ b/charts/kube-prometheus-stack/templates/alertmanager/servicemonitor.yaml @@ -36,17 +36,15 @@ spec: bearerTokenFile: {{ .Values.alertmanager.serviceMonitor.bearerTokenFile }} {{- end }} {{- if .Values.alertmanager.serviceMonitor.tlsConfig }} - tlsConfig: {{ toYaml .Values.alertmanager.serviceMonitor.tlsConfig | nindent 6 }} + tlsConfig: {{- toYaml .Values.alertmanager.serviceMonitor.tlsConfig | nindent 6 }} {{- end }} path: "{{ trimSuffix "/" .Values.alertmanager.alertmanagerSpec.routePrefix }}/metrics" -{{- if .Values.alertmanager.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ tpl (toYaml .Values.alertmanager.serviceMonitor.metricRelabelings | indent 6) . }} -{{- end }} -{{- if .Values.alertmanager.serviceMonitor.relabelings }} - relabelings: -{{ toYaml .Values.alertmanager.serviceMonitor.relabelings | indent 6 }} -{{- end }} + {{- if .Values.alertmanager.serviceMonitor.metricRelabelings }} + metricRelabelings: {{- tpl (toYaml .Values.alertmanager.serviceMonitor.metricRelabelings | nindent 6) . }} + {{- end }} + {{- if .Values.alertmanager.serviceMonitor.relabelings }} + relabelings: {{- toYaml .Values.alertmanager.serviceMonitor.relabelings | nindent 6 }} + {{- end }} - port: reloader-web {{- if .Values.alertmanager.serviceMonitor.interval }} interval: {{ .Values.alertmanager.serviceMonitor.interval }} @@ -61,15 +59,38 @@ spec: bearerTokenFile: {{ .Values.alertmanager.serviceMonitor.bearerTokenFile }} {{- end }} {{- if .Values.alertmanager.serviceMonitor.tlsConfig }} - tlsConfig: {{ toYaml .Values.alertmanager.serviceMonitor.tlsConfig | nindent 6 }} + tlsConfig: {{- toYaml .Values.alertmanager.serviceMonitor.tlsConfig | nindent 6 }} {{- end }} path: "/metrics" -{{- if .Values.alertmanager.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ tpl (toYaml .Values.alertmanager.serviceMonitor.metricRelabelings | indent 6) . }} -{{- end }} -{{- if .Values.alertmanager.serviceMonitor.relabelings }} - relabelings: -{{ toYaml .Values.alertmanager.serviceMonitor.relabelings | indent 6 }} -{{- end }} + {{- if .Values.alertmanager.serviceMonitor.metricRelabelings }} + metricRelabelings: {{- tpl (toYaml .Values.alertmanager.serviceMonitor.metricRelabelings | nindent 6) . }} + {{- end }} + {{- if .Values.alertmanager.serviceMonitor.relabelings }} + relabelings: {{- toYaml .Values.alertmanager.serviceMonitor.relabelings | nindent 6 }} + {{- end }} + {{- range .Values.alertmanager.serviceMonitor.additionalEndpoints }} + - port: {{ .port }} + {{- if or $.Values.alertmanager.serviceMonitor.interval .interval }} + interval: {{ default $.Values.alertmanager.serviceMonitor.interval .interval }} + {{- end }} + {{- if or $.Values.alertmanager.serviceMonitor.proxyUrl .proxyUrl }} + proxyUrl: {{ default $.Values.alertmanager.serviceMonitor.proxyUrl .proxyUrl }} + {{- end }} + {{- if or $.Values.alertmanager.serviceMonitor.scheme .scheme }} + scheme: {{ default $.Values.alertmanager.serviceMonitor.scheme .scheme }} + {{- end }} + {{- if or $.Values.alertmanager.serviceMonitor.bearerTokenFile .bearerTokenFile }} + bearerTokenFile: {{ default $.Values.alertmanager.serviceMonitor.bearerTokenFile .bearerTokenFile }} + {{- end }} + {{- if or $.Values.alertmanager.serviceMonitor.tlsConfig .tlsConfig }} + tlsConfig: {{- default $.Values.alertmanager.serviceMonitor.tlsConfig .tlsConfig | toYaml | nindent 6 }} + {{- end }} + path: {{ .path }} + {{- if or $.Values.alertmanager.serviceMonitor.metricRelabelings .metricRelabelings }} + metricRelabelings: {{- tpl (default $.Values.alertmanager.serviceMonitor.metricRelabelings .metricRelabelings | toYaml | nindent 6) . }} + {{- end }} + {{- if or $.Values.alertmanager.serviceMonitor.relabelings .relabelings }} + relabelings: {{- default $.Values.alertmanager.serviceMonitor.relabelings .relabelings | toYaml | nindent 6 }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/prometheus/servicemonitor.yaml b/charts/kube-prometheus-stack/templates/prometheus/servicemonitor.yaml index 12f66b80f345..e5d2389d9d9e 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/servicemonitor.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/servicemonitor.yaml @@ -29,20 +29,18 @@ spec: scheme: {{ .Values.prometheus.serviceMonitor.scheme }} {{- end }} {{- if .Values.prometheus.serviceMonitor.tlsConfig }} - tlsConfig: {{ toYaml .Values.prometheus.serviceMonitor.tlsConfig | nindent 6 }} + tlsConfig: {{- toYaml .Values.prometheus.serviceMonitor.tlsConfig | nindent 6 }} {{- end }} {{- if .Values.prometheus.serviceMonitor.bearerTokenFile }} bearerTokenFile: {{ .Values.prometheus.serviceMonitor.bearerTokenFile }} {{- end }} path: "{{ trimSuffix "/" .Values.prometheus.prometheusSpec.routePrefix }}/metrics" -{{- if .Values.prometheus.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ tpl (toYaml .Values.prometheus.serviceMonitor.metricRelabelings | indent 6) . }} -{{- end }} -{{- if .Values.prometheus.serviceMonitor.relabelings }} - relabelings: -{{ toYaml .Values.prometheus.serviceMonitor.relabelings | indent 6 }} -{{- end }} + {{- if .Values.prometheus.serviceMonitor.metricRelabelings }} + metricRelabelings: {{- tpl (toYaml .Values.prometheus.serviceMonitor.metricRelabelings | nindent 6) . }} + {{- end }} + {{- if .Values.prometheus.serviceMonitor.relabelings }} + relabelings: {{- toYaml .Values.prometheus.serviceMonitor.relabelings | nindent 6 }} + {{- end }} - port: reloader-web {{- if .Values.prometheus.serviceMonitor.interval }} interval: {{ .Values.prometheus.serviceMonitor.interval }} @@ -51,18 +49,41 @@ spec: scheme: {{ .Values.prometheus.serviceMonitor.scheme }} {{- end }} {{- if .Values.prometheus.serviceMonitor.tlsConfig }} - tlsConfig: {{ toYaml .Values.prometheus.serviceMonitor.tlsConfig | nindent 6 }} + tlsConfig: {{- toYaml .Values.prometheus.serviceMonitor.tlsConfig | nindent 6 }} {{- end }} {{- if .Values.prometheus.serviceMonitor.bearerTokenFile }} bearerTokenFile: {{ .Values.prometheus.serviceMonitor.bearerTokenFile }} {{- end }} path: "/metrics" -{{- if .Values.prometheus.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ tpl (toYaml .Values.prometheus.serviceMonitor.metricRelabelings | indent 6) . }} -{{- end }} -{{- if .Values.prometheus.serviceMonitor.relabelings }} - relabelings: -{{ toYaml .Values.prometheus.serviceMonitor.relabelings | indent 6 }} -{{- end }} + {{- if .Values.prometheus.serviceMonitor.metricRelabelings }} + metricRelabelings: {{- tpl (toYaml .Values.prometheus.serviceMonitor.metricRelabelings | nindent 6) . }} + {{- end }} + {{- if .Values.prometheus.serviceMonitor.relabelings }} + relabelings: {{- toYaml .Values.prometheus.serviceMonitor.relabelings | nindent 6 }} + {{- end }} + {{- range .Values.prometheus.serviceMonitor.additionalEndpoints }} + - port: {{ .port }} + {{- if or $.Values.prometheus.serviceMonitor.interval .interval }} + interval: {{ default $.Values.prometheus.serviceMonitor.interval .interval }} + {{- end }} + {{- if or $.Values.prometheus.serviceMonitor.proxyUrl .proxyUrl }} + proxyUrl: {{ default $.Values.prometheus.serviceMonitor.proxyUrl .proxyUrl }} + {{- end }} + {{- if or $.Values.prometheus.serviceMonitor.scheme .scheme }} + scheme: {{ default $.Values.prometheus.serviceMonitor.scheme .scheme }} + {{- end }} + {{- if or $.Values.prometheus.serviceMonitor.bearerTokenFile .bearerTokenFile }} + bearerTokenFile: {{ default $.Values.prometheus.serviceMonitor.bearerTokenFile .bearerTokenFile }} + {{- end }} + {{- if or $.Values.prometheus.serviceMonitor.tlsConfig .tlsConfig }} + tlsConfig: {{- default $.Values.prometheus.serviceMonitor.tlsConfig .tlsConfig | toYaml | nindent 6 }} + {{- end }} + path: {{ .path }} + {{- if or $.Values.prometheus.serviceMonitor.metricRelabelings .metricRelabelings }} + metricRelabelings: {{- tpl (default $.Values.prometheus.serviceMonitor.metricRelabelings .metricRelabelings | toYaml | nindent 6) . }} + {{- end }} + {{- if or $.Values.prometheus.serviceMonitor.relabelings .relabelings }} + relabelings: {{- default $.Values.prometheus.serviceMonitor.relabelings .relabelings | toYaml | nindent 6 }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/thanos-ruler/servicemonitor.yaml b/charts/kube-prometheus-stack/templates/thanos-ruler/servicemonitor.yaml index 7f72688a1b8f..83bd8ba216a4 100644 --- a/charts/kube-prometheus-stack/templates/thanos-ruler/servicemonitor.yaml +++ b/charts/kube-prometheus-stack/templates/thanos-ruler/servicemonitor.yaml @@ -35,15 +35,38 @@ spec: bearerTokenFile: {{ .Values.thanosRuler.serviceMonitor.bearerTokenFile }} {{- end }} {{- if .Values.thanosRuler.serviceMonitor.tlsConfig }} - tlsConfig: {{ toYaml .Values.thanosRuler.serviceMonitor.tlsConfig | nindent 6 }} + tlsConfig: {{- toYaml .Values.thanosRuler.serviceMonitor.tlsConfig | nindent 6 }} {{- end }} path: "{{ trimSuffix "/" .Values.thanosRuler.thanosRulerSpec.routePrefix }}/metrics" -{{- if .Values.thanosRuler.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ tpl (toYaml .Values.thanosRuler.serviceMonitor.metricRelabelings | indent 6) . }} -{{- end }} -{{- if .Values.thanosRuler.serviceMonitor.relabelings }} - relabelings: -{{ toYaml .Values.thanosRuler.serviceMonitor.relabelings | indent 6 }} -{{- end }} + {{- if .Values.thanosRuler.serviceMonitor.metricRelabelings }} + metricRelabelings: {{- tpl (toYaml .Values.thanosRuler.serviceMonitor.metricRelabelings | nindent 6) . }} + {{- end }} + {{- if .Values.thanosRuler.serviceMonitor.relabelings }} + relabelings: {{- toYaml .Values.thanosRuler.serviceMonitor.relabelings | nindent 6 }} + {{- end }} + {{- range .Values.thanosRuler.serviceMonitor.additionalEndpoints }} + - port: {{ .port }} + {{- if or $.Values.thanosRuler.serviceMonitor.interval .interval }} + interval: {{ default $.Values.thanosRuler.serviceMonitor.interval .interval }} + {{- end }} + {{- if or $.Values.thanosRuler.serviceMonitor.proxyUrl .proxyUrl }} + proxyUrl: {{ default $.Values.thanosRuler.serviceMonitor.proxyUrl .proxyUrl }} + {{- end }} + {{- if or $.Values.thanosRuler.serviceMonitor.scheme .scheme }} + scheme: {{ default $.Values.thanosRuler.serviceMonitor.scheme .scheme }} + {{- end }} + {{- if or $.Values.thanosRuler.serviceMonitor.bearerTokenFile .bearerTokenFile }} + bearerTokenFile: {{ default $.Values.thanosRuler.serviceMonitor.bearerTokenFile .bearerTokenFile }} + {{- end }} + {{- if or $.Values.thanosRuler.serviceMonitor.tlsConfig .tlsConfig }} + tlsConfig: {{- default $.Values.thanosRuler.serviceMonitor.tlsConfig .tlsConfig | toYaml | nindent 6 }} + {{- end }} + path: {{ .path }} + {{- if or $.Values.thanosRuler.serviceMonitor.metricRelabelings .metricRelabelings }} + metricRelabelings: {{- tpl (default $.Values.thanosRuler.serviceMonitor.metricRelabelings .metricRelabelings | toYaml | nindent 6) . }} + {{- end }} + {{- if or $.Values.thanosRuler.serviceMonitor.relabelings .relabelings }} + relabelings: {{- default $.Values.thanosRuler.serviceMonitor.relabelings .relabelings | toYaml | nindent 6 }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/kube-prometheus-stack/values.yaml b/charts/kube-prometheus-stack/values.yaml index 80c08935f180..e9930ba86d30 100644 --- a/charts/kube-prometheus-stack/values.yaml +++ b/charts/kube-prometheus-stack/values.yaml @@ -463,11 +463,14 @@ alertmanager: ## ## Additional ports to open for Alertmanager service + ## additionalPorts: [] - # additionalPorts: - # - name: authenticated + # - name: oauth-proxy # port: 8081 # targetPort: 8081 + # - name: oauth-metrics + # port: 8082 + # targetPort: 8082 externalIPs: [] loadBalancerIP: "" @@ -584,6 +587,12 @@ alertmanager: # replacement: $1 # action: replace + ## Additional Endpoints + ## + additionalEndpoints: [] + # - port: oauth-metrics + # path: /metrics + ## Settings affecting alertmanagerSpec ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#alertmanagerspec ## @@ -806,15 +815,19 @@ alertmanager: containers: [] # containers: # - name: oauth-proxy - # image: quay.io/oauth2-proxy/oauth2-proxy:v7.3.0 + # image: quay.io/oauth2-proxy/oauth2-proxy:v7.5.1 # args: # - --upstream=http://127.0.0.1:9093 # - --http-address=0.0.0.0:8081 + # - --metrics-address=0.0.0.0:8082 # - ... # ports: # - containerPort: 8081 # name: oauth-proxy # protocol: TCP + # - containerPort: 8082 + # name: oauth-metrics + # protocol: TCP # resources: {} # Additional volumes on the output StatefulSet definition. @@ -2153,7 +2166,7 @@ prometheusOperator: nodePortTls: 30443 - ## Additional ports to open for Prometheus service + ## Additional ports to open for Prometheus operator service ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services ## additionalPorts: [] @@ -2613,12 +2626,16 @@ prometheus: ## type: ClusterIP - ## Additional port to define in the Service + ## Additional ports to open for Prometheus service + ## additionalPorts: [] # additionalPorts: - # - name: authenticated + # - name: oauth-proxy # port: 8081 # targetPort: 8081 + # - name: oauth-metrics + # port: 8082 + # targetPort: 8082 ## Consider that all endpoints are considered "ready" even if the Pods themselves are not ## Ref: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceSpec @@ -2861,6 +2878,12 @@ prometheus: # replacement: $1 # action: replace + ## Additional Endpoints + ## + additionalEndpoints: [] + # - port: oauth-metrics + # path: /metrics + ## Settings affecting prometheusSpec ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#prometheusspec ## @@ -3414,15 +3437,19 @@ prometheus: containers: [] # containers: # - name: oauth-proxy - # image: quay.io/oauth2-proxy/oauth2-proxy:v7.3.0 + # image: quay.io/oauth2-proxy/oauth2-proxy:v7.5.1 # args: - # - --upstream=http://127.0.0.1:9093 + # - --upstream=http://127.0.0.1:9090 # - --http-address=0.0.0.0:8081 + # - --metrics-address=0.0.0.0:8082 # - ... # ports: # - containerPort: 8081 # name: oauth-proxy # protocol: TCP + # - containerPort: 8082 + # name: oauth-metrics + # protocol: TCP # resources: {} ## InitContainers allows injecting additional initContainers. This is meant to allow doing some changes @@ -3844,6 +3871,12 @@ thanosRuler: # replacement: $1 # action: replace + ## Additional Endpoints + ## + additionalEndpoints: [] + # - port: oauth-metrics + # path: /metrics + ## Settings affecting thanosRulerpec ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#thanosrulerspec ##