From 9e4b6ed1201b43c7a3e03ec41d2fd536e32abc9d Mon Sep 17 00:00:00 2001 From: Yisheng Cai Date: Thu, 21 Nov 2024 16:19:51 +0800 Subject: [PATCH 1/3] Make buildin prom compatible with mergeMetrics feature --- .../templates/prometheus/prometheus-configmap.yaml | 2 +- charts/sn-platform-slim/values.yaml | 2 +- .../sn-platform/templates/prometheus/prometheus-configmap.yaml | 2 +- charts/sn-platform/values.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml b/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml index 79aa35c5b..78d915d6b 100644 --- a/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml +++ b/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml @@ -53,7 +53,7 @@ data: - {{ template "pulsar.namespace" . }} {{- end }} {{- if .Values.istio.enabled }} -{{- if .Values.istio.migration }} +{{- if or .Values.istio.migration .Values.istio.mergeMetrics }} scheme: http enable_http2: false {{- else }} diff --git a/charts/sn-platform-slim/values.yaml b/charts/sn-platform-slim/values.yaml index f00e86a62..98e27efc9 100644 --- a/charts/sn-platform-slim/values.yaml +++ b/charts/sn-platform-slim/values.yaml @@ -2144,7 +2144,7 @@ istio: migration: false # istio labels used to inject sidecars if it's not `sidecar.istio.io/inject: "true"` labels: {} - # If you're using the prometheus in this chart, please keep mergeMetrics disabled. + # mergeMetrics should be enabled if you want to scrape pulsar metrics from an external prometheus not running on Istio mergeMetrics: false gateway: # gateway selector if it's not `istio: ingressgateway` diff --git a/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml b/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml index 79aa35c5b..78d915d6b 100644 --- a/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml +++ b/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml @@ -53,7 +53,7 @@ data: - {{ template "pulsar.namespace" . }} {{- end }} {{- if .Values.istio.enabled }} -{{- if .Values.istio.migration }} +{{- if or .Values.istio.migration .Values.istio.mergeMetrics }} scheme: http enable_http2: false {{- else }} diff --git a/charts/sn-platform/values.yaml b/charts/sn-platform/values.yaml index fac1b57d9..1ce070180 100644 --- a/charts/sn-platform/values.yaml +++ b/charts/sn-platform/values.yaml @@ -2509,7 +2509,7 @@ istio: migration: false # istio labels used to inject sidecars if it's not `sidecar.istio.io/inject: "true"` labels: {} - # If you're using the prometheus in this chart, please keep mergeMetrics disabled. + # mergeMetrics should be enabled if you want to scrape pulsar metrics from an external prometheus not running on Istio mergeMetrics: false gateway: # gateway selector if it's not `istio: ingressgateway` From 334691256c0c7978e20c70a2b84b764e56b18b6c Mon Sep 17 00:00:00 2001 From: Yisheng Cai Date: Thu, 21 Nov 2024 20:37:31 +0800 Subject: [PATCH 2/3] Disable prom Istio when mergeMetrics --- charts/sn-platform-slim/templates/_helpers.tpl | 9 +++++++++ .../templates/grafana/grafana-deployment.yaml | 4 ++++ .../templates/grafana/grafana-statefulset.yaml | 4 ++++ .../templates/prometheus/prometheus-configmap.yaml | 4 ++-- .../templates/prometheus/prometheus-statefulset.yaml | 10 +++++++--- charts/sn-platform-slim/values.yaml | 5 +++-- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/charts/sn-platform-slim/templates/_helpers.tpl b/charts/sn-platform-slim/templates/_helpers.tpl index 2fbfc702e..196895a22 100644 --- a/charts/sn-platform-slim/templates/_helpers.tpl +++ b/charts/sn-platform-slim/templates/_helpers.tpl @@ -77,6 +77,15 @@ sidecar.istio.io/inject: "true" {{- end }} {{- end }} +{{/* +Create the monitoring template labels. +*/}} +{{- define "pulsar.monitoring.template.labels" -}} +app: {{ template "pulsar.name" . }} +release: {{ .Release.Name }} +cluster: {{ template "pulsar.fullname" . }} +{{- end }} + {{/* Create the match labels. */}} diff --git a/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml b/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml index 3497c538d..33073324e 100644 --- a/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml +++ b/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml @@ -24,7 +24,11 @@ spec: template: metadata: labels: + {{- if and .Values.istio.enabled .Values.istio.mergeMetrics }} + {{- include "pulsar.monitoring.template.labels" . | nindent 8 }} + {{- else }} {{- include "pulsar.template.labels" . | nindent 8 }} + {{- end }} component: {{ .Values.grafana.component }} {{- with .Values.grafana.labels }} {{ toYaml . | indent 8 }} diff --git a/charts/sn-platform-slim/templates/grafana/grafana-statefulset.yaml b/charts/sn-platform-slim/templates/grafana/grafana-statefulset.yaml index e2c4abfc2..43cd5605c 100644 --- a/charts/sn-platform-slim/templates/grafana/grafana-statefulset.yaml +++ b/charts/sn-platform-slim/templates/grafana/grafana-statefulset.yaml @@ -25,7 +25,11 @@ spec: template: metadata: labels: + {{- if and .Values.istio.enabled .Values.istio.mergeMetrics }} + {{- include "pulsar.monitoring.template.labels" . | nindent 8 }} + {{- else }} {{- include "pulsar.template.labels" . | nindent 8 }} + {{- end }} component: {{ .Values.grafana.component }} annotations: checksum/config: {{ include (print $.Template.BasePath "/grafana/grafana-configmap.yaml") . | sha256sum }} diff --git a/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml b/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml index 78d915d6b..36443c15c 100644 --- a/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml +++ b/charts/sn-platform-slim/templates/prometheus/prometheus-configmap.yaml @@ -52,8 +52,8 @@ data: names: - {{ template "pulsar.namespace" . }} {{- end }} -{{- if .Values.istio.enabled }} -{{- if or .Values.istio.migration .Values.istio.mergeMetrics }} +{{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics) }} +{{- if .Values.istio.migration }} scheme: http enable_http2: false {{- else }} diff --git a/charts/sn-platform-slim/templates/prometheus/prometheus-statefulset.yaml b/charts/sn-platform-slim/templates/prometheus/prometheus-statefulset.yaml index 7ab7d8770..c2b72c7b2 100644 --- a/charts/sn-platform-slim/templates/prometheus/prometheus-statefulset.yaml +++ b/charts/sn-platform-slim/templates/prometheus/prometheus-statefulset.yaml @@ -27,13 +27,17 @@ spec: template: metadata: labels: + {{- if and .Values.istio.enabled .Values.istio.mergeMetrics }} + {{- include "pulsar.monitoring.template.labels" . | nindent 8 }} + {{- else }} {{- include "pulsar.template.labels" . | nindent 8 }} + {{- end }} component: {{ .Values.prometheus.component }} {{- with .Values.prometheus.labels }} {{ toYaml . | indent 8 }} {{- end }} annotations: - {{- if .Values.istio.enabled }} + {{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics ) }} # ref: https://istio.io/latest/docs/ops/integrations/prometheus/#tls-settings traffic.sidecar.istio.io/includeOutboundIPRanges: "" # do not intercept any outbound traffic # configure an env variable `OUTPUT_CERTS` to write certificates to the given folder @@ -154,7 +158,7 @@ spec: mountPath: /etc/config - name: "{{ template "pulsar.fullname" . }}-{{ .Values.prometheus.component }}-{{ .Values.prometheus.volumes.data.name }}" mountPath: /prometheus - {{- if .Values.istio.enabled }} + {{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics ) }} - name: istio-certs mountPath: /etc/prom-certs/ {{- end }} @@ -163,7 +167,7 @@ spec: - name: config-volume configMap: name: "{{ template "pulsar.fullname" . }}-{{ .Values.prometheus.component }}" - {{- if .Values.istio.enabled }} + {{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics )}} - emptyDir: medium: Memory name: istio-certs diff --git a/charts/sn-platform-slim/values.yaml b/charts/sn-platform-slim/values.yaml index 98e27efc9..e30ffe192 100644 --- a/charts/sn-platform-slim/values.yaml +++ b/charts/sn-platform-slim/values.yaml @@ -794,7 +794,7 @@ bookkeeper: enabled: false minReplicas: 1 maxReplicas: 4 - metrics: {} + metrics: [] # The field logConfig can be used to change the log level and log format of pods. # The logConfig field is optional. If it is not specified, the component will use the default log configuration /pulsar/conf/log4j2.yaml. # f it is specified will dynamically change the log level and log format of the component by changing the CR. @@ -1038,7 +1038,7 @@ broker: enabled: false minReplicas: 1 maxReplicas: 4 - metrics: {} + metrics: [] # The field logConfig can be used to change the log level and log format of pods. # The logConfig field is optional. If it is not specified, the component will use the default log configuration /pulsar/conf/log4j2.yaml. # If it is specified will dynamically change the log level and log format of the component by changing the CR. @@ -2145,6 +2145,7 @@ istio: # istio labels used to inject sidecars if it's not `sidecar.istio.io/inject: "true"` labels: {} # mergeMetrics should be enabled if you want to scrape pulsar metrics from an external prometheus not running on Istio + # prometheus and grafana will not be Istio injected if mergeMetrics is enabled mergeMetrics: false gateway: # gateway selector if it's not `istio: ingressgateway` From 66b8ba804a1fcfb3b8bda336160e43617859fd5b Mon Sep 17 00:00:00 2001 From: Yisheng Cai Date: Thu, 21 Nov 2024 20:37:37 +0800 Subject: [PATCH 3/3] Disable prom Istio when mergeMetrics --- charts/sn-platform/templates/_helpers.tpl | 9 +++++++++ .../templates/grafana/grafana-deployment.yaml | 4 ++++ .../templates/grafana/grafana-statefulset.yaml | 4 ++++ .../templates/prometheus/prometheus-configmap.yaml | 4 ++-- .../templates/prometheus/prometheus-statefulset.yaml | 10 +++++++--- charts/sn-platform/values.yaml | 1 + 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/charts/sn-platform/templates/_helpers.tpl b/charts/sn-platform/templates/_helpers.tpl index 11a489a21..ecb16b675 100644 --- a/charts/sn-platform/templates/_helpers.tpl +++ b/charts/sn-platform/templates/_helpers.tpl @@ -77,6 +77,15 @@ sidecar.istio.io/inject: "true" {{- end }} {{- end }} +{{/* +Create the monitoring template labels. +*/}} +{{- define "pulsar.monitoring.template.labels" -}} +app: {{ template "pulsar.name" . }} +release: {{ .Release.Name }} +cluster: {{ template "pulsar.fullname" . }} +{{- end }} + {{/* Create the match labels. */}} diff --git a/charts/sn-platform/templates/grafana/grafana-deployment.yaml b/charts/sn-platform/templates/grafana/grafana-deployment.yaml index a88e4cdb8..78116455c 100644 --- a/charts/sn-platform/templates/grafana/grafana-deployment.yaml +++ b/charts/sn-platform/templates/grafana/grafana-deployment.yaml @@ -24,7 +24,11 @@ spec: template: metadata: labels: + {{- if and .Values.istio.enabled .Values.istio.mergeMetrics }} + {{- include "pulsar.monitoring.template.labels" . | nindent 8 }} + {{- else }} {{- include "pulsar.template.labels" . | nindent 8 }} + {{- end }} component: {{ .Values.grafana.component }} {{- with .Values.grafana.labels }} {{ toYaml . | indent 8 }} diff --git a/charts/sn-platform/templates/grafana/grafana-statefulset.yaml b/charts/sn-platform/templates/grafana/grafana-statefulset.yaml index a2a5b5ea4..99683f0c2 100644 --- a/charts/sn-platform/templates/grafana/grafana-statefulset.yaml +++ b/charts/sn-platform/templates/grafana/grafana-statefulset.yaml @@ -25,7 +25,11 @@ spec: template: metadata: labels: + {{- if and .Values.istio.enabled .Values.istio.mergeMetrics }} + {{- include "pulsar.monitoring.template.labels" . | nindent 8 }} + {{- else }} {{- include "pulsar.template.labels" . | nindent 8 }} + {{- end }} component: {{ .Values.grafana.component }} annotations: checksum/config: {{ include (print $.Template.BasePath "/grafana/grafana-configmap.yaml") . | sha256sum }} diff --git a/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml b/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml index 78d915d6b..36443c15c 100644 --- a/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml +++ b/charts/sn-platform/templates/prometheus/prometheus-configmap.yaml @@ -52,8 +52,8 @@ data: names: - {{ template "pulsar.namespace" . }} {{- end }} -{{- if .Values.istio.enabled }} -{{- if or .Values.istio.migration .Values.istio.mergeMetrics }} +{{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics) }} +{{- if .Values.istio.migration }} scheme: http enable_http2: false {{- else }} diff --git a/charts/sn-platform/templates/prometheus/prometheus-statefulset.yaml b/charts/sn-platform/templates/prometheus/prometheus-statefulset.yaml index 7ab7d8770..0304b35b7 100644 --- a/charts/sn-platform/templates/prometheus/prometheus-statefulset.yaml +++ b/charts/sn-platform/templates/prometheus/prometheus-statefulset.yaml @@ -27,13 +27,17 @@ spec: template: metadata: labels: + {{- if and .Values.istio.enabled .Values.istio.mergeMetrics }} + {{- include "pulsar.monitoring.template.labels" . | nindent 8 }} + {{- else }} {{- include "pulsar.template.labels" . | nindent 8 }} + {{- end }} component: {{ .Values.prometheus.component }} {{- with .Values.prometheus.labels }} {{ toYaml . | indent 8 }} {{- end }} annotations: - {{- if .Values.istio.enabled }} + {{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics ) }} # ref: https://istio.io/latest/docs/ops/integrations/prometheus/#tls-settings traffic.sidecar.istio.io/includeOutboundIPRanges: "" # do not intercept any outbound traffic # configure an env variable `OUTPUT_CERTS` to write certificates to the given folder @@ -154,7 +158,7 @@ spec: mountPath: /etc/config - name: "{{ template "pulsar.fullname" . }}-{{ .Values.prometheus.component }}-{{ .Values.prometheus.volumes.data.name }}" mountPath: /prometheus - {{- if .Values.istio.enabled }} + {{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics ) }} - name: istio-certs mountPath: /etc/prom-certs/ {{- end }} @@ -163,7 +167,7 @@ spec: - name: config-volume configMap: name: "{{ template "pulsar.fullname" . }}-{{ .Values.prometheus.component }}" - {{- if .Values.istio.enabled }} + {{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics ) }} - emptyDir: medium: Memory name: istio-certs diff --git a/charts/sn-platform/values.yaml b/charts/sn-platform/values.yaml index 1ce070180..5752a2237 100644 --- a/charts/sn-platform/values.yaml +++ b/charts/sn-platform/values.yaml @@ -2510,6 +2510,7 @@ istio: # istio labels used to inject sidecars if it's not `sidecar.istio.io/inject: "true"` labels: {} # mergeMetrics should be enabled if you want to scrape pulsar metrics from an external prometheus not running on Istio + # prometheus and grafana will not be Istio injected if mergeMetrics is enabled mergeMetrics: false gateway: # gateway selector if it's not `istio: ingressgateway`