Skip to content

Commit

Permalink
Make build-in prom compatible with mergeMetrics feature (#1192)
Browse files Browse the repository at this point in the history
* Make buildin prom compatible with mergeMetrics feature

* Disable prom Istio when mergeMetrics

* Disable prom Istio when mergeMetrics

(cherry picked from commit d0965ba)
  • Loading branch information
ciiiii authored and ericsyh committed Nov 22, 2024
1 parent f9455c7 commit aab2b7e
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 14 deletions.
9 changes: 9 additions & 0 deletions charts/sn-platform-slim/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ data:
names:
- {{ template "pulsar.namespace" . }}
{{- end }}
{{- if .Values.istio.enabled }}
{{- if .Values.istio.migration }}
{{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics) }}
{{- if .Values.istio.migration }}
scheme: http
enable_http2: false
{{- else }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,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
Expand Down Expand Up @@ -169,7 +173,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 }}
Expand All @@ -178,7 +182,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
Expand Down
7 changes: 4 additions & 3 deletions charts/sn-platform-slim/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,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.
Expand Down Expand Up @@ -1053,7 +1053,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.
Expand Down Expand Up @@ -2159,7 +2159,8 @@ 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
# prometheus and grafana will not be Istio injected if mergeMetrics is enabled
mergeMetrics: false
gateway:
# gateway selector if it's not `istio: ingressgateway`
Expand Down
9 changes: 9 additions & 0 deletions charts/sn-platform/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/}}
Expand Down
4 changes: 4 additions & 0 deletions charts/sn-platform/templates/grafana/grafana-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/sn-platform/templates/grafana/grafana-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ data:
names:
- {{ template "pulsar.namespace" . }}
{{- end }}
{{- if .Values.istio.enabled }}
{{- if .Values.istio.migration }}
{{- if and .Values.istio.enabled (not .Values.istio.mergeMetrics) }}
{{- if .Values.istio.migration }}
scheme: http
enable_http2: false
{{- else }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,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
Expand Down Expand Up @@ -164,7 +168,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 }}
Expand All @@ -173,7 +177,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
Expand Down
3 changes: 2 additions & 1 deletion charts/sn-platform/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,8 @@ 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
# prometheus and grafana will not be Istio injected if mergeMetrics is enabled
mergeMetrics: false
gateway:
# gateway selector if it's not `istio: ingressgateway`
Expand Down

0 comments on commit aab2b7e

Please sign in to comment.