From 502980f426a585d0e2725250c0b9eaecc3d98c2e Mon Sep 17 00:00:00 2001 From: Jorge Turrado Ferrero Date: Tue, 6 Jun 2023 10:42:29 +0200 Subject: [PATCH] Remove deprecated prometheus metrics from MS (#432) Signed-off-by: Jorge Turrado Signed-off-by: Jorge Turrado --- keda/README.md | 5 +---- keda/templates/manager/service.yaml | 4 ++++ keda/templates/metrics-server/deployment.yaml | 13 ++----------- keda/templates/metrics-server/podmonitor.yaml | 4 ++-- keda/templates/metrics-server/service.yaml | 19 +++++++++---------- .../metrics-server/servicemonitor.yaml | 2 +- keda/values.yaml | 5 +---- 7 files changed, 20 insertions(+), 32 deletions(-) diff --git a/keda/README.md b/keda/README.md index 43d4572a..5bf0bff6 100644 --- a/keda/README.md +++ b/keda/README.md @@ -144,14 +144,11 @@ their default values. | `http.timeout` | The default HTTP timeout to use for all scalers that use raw HTTP clients (some scalers use SDKs to access target services. These have built-in HTTP clients, and the timeout does not necessarily apply to them) | `` | | `http.minTlsVersion` | The minimum TLS version to use for all scalers that use raw HTTP clients (some scalers use SDKs to access target services. These have built-in HTTP clients, and this value does not necessarily apply to them) | `` | | `service.annotations` | Annotations to add the KEDA Metric Server service | `{}` | -| `service.portHttp` | Service HTTP port for KEDA Metric Server service | `80` | -| `service.portHttpTarget` | Service HTTP port for KEDA Metric Server container | `8080` | | `service.portHttps` | HTTPS port for KEDA Metric Server service | `443` | | `service.portHttpsTarget` | HTTPS port for KEDA Metric Server container | `6443` | | `prometheus.metricServer.enabled` | Enable metric server Prometheus metrics expose | `false` | -| `prometheus.metricServer.port` | HTTP port used for exposing metrics server prometheus metrics | `9022` | +| `prometheus.metricServer.port` | HTTP port used for exposing metrics server prometheus metrics | `8088` | | `prometheus.metricServer.portName` | HTTP port name for exposing metrics server prometheus metrics | `metrics` | -| `prometheus.metricServer.path` | Path used for exposing metric server prometheus metrics | `/metrics` | | `prometheus.metricServer.podMonitor.enabled` | Enable monitoring for metric server using podMonitor crd (prometheus operator) | `false` | | `prometheus.metricServer.podMonitor.interval` | Scraping interval for metric server using podMonitor crd (prometheus operator) | `` | | `prometheus.metricServer.podMonitor.scrapeTimeout` | Scraping timeout for metric server using podMonitor crd (prometheus operator) | `` | diff --git a/keda/templates/manager/service.yaml b/keda/templates/manager/service.yaml index 0d9a3304..2b26ce9b 100644 --- a/keda/templates/manager/service.yaml +++ b/keda/templates/manager/service.yaml @@ -7,6 +7,10 @@ metadata: prometheus.io/port: {{ .Values.prometheus.operator.port | quote }} prometheus.io/path: "/metrics" {{- end }} + {{- toYaml .Values.additionalAnnotations | nindent 4 }} + {{- range $key, $value := .Values.service.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/metrics-server/deployment.yaml b/keda/templates/metrics-server/deployment.yaml index 30a6554d..d162090f 100644 --- a/keda/templates/metrics-server/deployment.yaml +++ b/keda/templates/metrics-server/deployment.yaml @@ -107,7 +107,7 @@ spec: {{- end }} args: - /usr/local/bin/keda-adapter - - --port={{ .Values.service.portHttpTarget }} + - --port={{ .Values.prometheus.metricServer.port }} - --secure-port={{ .Values.service.portHttpsTarget }} - --logtostderr=true - --metrics-service-address={{ .Values.operator.name }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:9666 @@ -115,10 +115,6 @@ spec: - --tls-cert-file={{ .Values.certificates.mountPath }}/tls.crt - --tls-private-key-file={{ .Values.certificates.mountPath }}/tls.key - --cert-dir={{ .Values.certificates.mountPath }} - {{- if .Values.prometheus.metricServer.enabled }} - - --metrics-port={{ .Values.prometheus.metricServer.port }} - - --metrics-path={{ .Values.prometheus.metricServer.path }} - {{- end }} - --v={{ .Values.logging.metricServer.level }} {{- range $key, $value := .Values.extraArgs.metricsAdapter }} - --{{ $key }}={{ $value }} @@ -127,14 +123,9 @@ spec: - containerPort: {{ .Values.service.portHttpsTarget }} name: https protocol: TCP - - containerPort: {{ .Values.service.portHttpTarget }} - name: http - protocol: TCP - {{- if .Values.prometheus.metricServer.enabled }} - containerPort: {{ .Values.prometheus.metricServer.port }} - name: metrics + name: {{ .Values.prometheus.metricServer.portName }} protocol: TCP - {{- end }} volumeMounts: - mountPath: {{ .Values.certificates.mountPath }} name: certificates diff --git a/keda/templates/metrics-server/podmonitor.yaml b/keda/templates/metrics-server/podmonitor.yaml index 93a741ef..40476abd 100644 --- a/keda/templates/metrics-server/podmonitor.yaml +++ b/keda/templates/metrics-server/podmonitor.yaml @@ -16,8 +16,8 @@ metadata: {{- end }} spec: podMetricsEndpoints: - - port: metrics - path: {{ .Values.prometheus.metricServer.path }} + - port: {{ .Values.prometheus.metricServer.portName }} + path: /metrics {{- with .Values.prometheus.metricServer.podMonitor.interval }} interval: {{ . }} {{- end }} diff --git a/keda/templates/metrics-server/service.yaml b/keda/templates/metrics-server/service.yaml index 5b64b952..2806a175 100644 --- a/keda/templates/metrics-server/service.yaml +++ b/keda/templates/metrics-server/service.yaml @@ -8,25 +8,24 @@ metadata: name: {{ .Values.operator.name }}-metrics-apiserver namespace: {{ .Release.Namespace }} annotations: - {{- toYaml .Values.additionalAnnotations | nindent 4 }} - {{- range $key, $value := .Values.service.annotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} + {{- if and .Values.prometheus.metricServer.enabled ( not (or .Values.prometheus.metricServer.podMonitor.enabled .Values.prometheus.metricServer.serviceMonitor.enabled )) }} + prometheus.io/scrape: "true" + prometheus.io/port: {{ .Values.prometheus.metricServer.port | quote }} + prometheus.io/path: "/metrics" + {{- end }} + {{- toYaml .Values.additionalAnnotations | nindent 4 }} + {{- range $key, $value := .Values.service.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} spec: ports: - name: https port: {{ .Values.service.portHttps }} targetPort: {{ .Values.service.portHttpsTarget }} protocol: TCP - - name: http - port: {{ .Values.service.portHttp }} - targetPort: {{ .Values.service.portHttpTarget }} - protocol: TCP - {{- if .Values.prometheus.metricServer.enabled }} - name: {{ .Values.prometheus.metricServer.portName }} port: {{ .Values.prometheus.metricServer.port }} targetPort: {{ .Values.prometheus.metricServer.port }} protocol: TCP - {{- end }} selector: app: {{ .Values.operator.name }}-metrics-apiserver diff --git a/keda/templates/metrics-server/servicemonitor.yaml b/keda/templates/metrics-server/servicemonitor.yaml index 450fdec9..b2598ac1 100644 --- a/keda/templates/metrics-server/servicemonitor.yaml +++ b/keda/templates/metrics-server/servicemonitor.yaml @@ -31,7 +31,7 @@ spec: {{- with .Values.prometheus.metricServer.serviceMonitor.targetPort }} targetPort: {{ . }} {{- end }} - path: {{ .Values.prometheus.metricServer.path }} + path: /metrics {{- with .Values.prometheus.metricServer.serviceMonitor.interval }} interval: {{ . }} {{- end }} diff --git a/keda/values.yaml b/keda/values.yaml index e7749300..85fd7596 100644 --- a/keda/values.yaml +++ b/keda/values.yaml @@ -269,8 +269,6 @@ podSecurityContext: service: type: ClusterIP - portHttp: 80 - portHttpTarget: 8080 portHttps: 443 portHttpsTarget: 6443 @@ -365,9 +363,8 @@ volumes: prometheus: metricServer: enabled: false - port: 9022 + port: 8080 portName: metrics - path: /metrics serviceMonitor: # Enables ServiceMonitor creation for the Prometheus Operator enabled: false