Skip to content

Commit

Permalink
[prometheus-rabbitmq-exporter] allow passing an external ConfigMap to…
Browse files Browse the repository at this point in the history
… override env vars (prometheus-community#3582)

* enable supplying an external configmap to override rmq exporter configs

Signed-off-by: David Ohayon <david.ohayon@traderepublic.com>

* Update charts/prometheus-rabbitmq-exporter/templates/configmap.yaml

Co-authored-by: MH <zanhsieh@gmail.com>
Signed-off-by: David O <48397009+davido912@users.noreply.github.com>

* Update charts/prometheus-rabbitmq-exporter/templates/deployment.yaml

Co-authored-by: MH <zanhsieh@gmail.com>
Signed-off-by: David O <48397009+davido912@users.noreply.github.com>

---------

Signed-off-by: David Ohayon <david.ohayon@traderepublic.com>
Signed-off-by: David O <48397009+davido912@users.noreply.github.com>
Co-authored-by: MH <zanhsieh@gmail.com>
  • Loading branch information
2 people authored and Matiasmct committed Aug 25, 2023
1 parent 4d3a5dc commit be0d387
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-rabbitmq-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: Rabbitmq metrics exporter for prometheus
name: prometheus-rabbitmq-exporter
version: 1.7.0
version: 1.8.0
appVersion: v0.29.0
home: https://github.com/kbudde/rabbitmq_exporter
sources:
Expand Down
5 changes: 5 additions & 0 deletions charts/prometheus-rabbitmq-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}


{{- define "prometheus-rabbitmq-exporter.configMapName" -}}
{{ template "prometheus-rabbitmq-exporter.fullname" . }}-config
{{- end -}}
28 changes: 28 additions & 0 deletions charts/prometheus-rabbitmq-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "prometheus-rabbitmq-exporter.configMapName" . }}
labels:
app: {{ template "prometheus-rabbitmq-exporter.name" . }}
chart: {{ template "prometheus-rabbitmq-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- toYaml . | indent 4 }}
{{- end }}
data:
RABBIT_URL: {{ .Values.rabbitmq.url | quote }}
RABBIT_USER: {{ .Values.rabbitmq.user | quote }}
PUBLISH_PORT: {{ .Values.service.internalPort | quote }}
LOG_LEVEL: {{ .Values.loglevel | quote }}
RABBIT_CAPABILITIES: {{ .Values.rabbitmq.capabilities | quote }}
INCLUDE_QUEUES: {{ .Values.rabbitmq.include_queues | quote }}
INCLUDE_VHOST: {{ .Values.rabbitmq.include_vhost | quote }}
SKIP_QUEUES: {{ .Values.rabbitmq.skip_queues | quote }}
SKIPVERIFY: {{ .Values.rabbitmq.skip_verify | quote }}
SKIP_VHOST: {{ .Values.rabbitmq.skip_vhost | quote }}
RABBIT_EXPORTERS: {{ .Values.rabbitmq.exporters | quote }}
OUTPUT_FORMAT: {{ .Values.rabbitmq.output_format | quote }}
RABBIT_TIMEOUT: {{ .Values.rabbitmq.timeout | quote }}
MAX_QUEUES: {{ .Values.rabbitmq.max_queues | quote }}
EXCLUDE_METRICS: {{ .Values.rabbitmq.excludeMetrics | quote }}
45 changes: 11 additions & 34 deletions charts/prometheus-rabbitmq-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ spec:
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
annotations:
{{ toYaml .Values.annotations | indent 8 }}
checksum/exporter-config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- with .Values.annotations }}
{{- toYaml .| nindent 8 }}
{{- end }}
spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
Expand All @@ -38,47 +41,21 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ template "prometheus-rabbitmq-exporter.configMapName" . }}
{{- if .Values.rabbitmq.configMapOverrideReference }}
- configMapRef:
name: {{ .Values.rabbitmq.configMapOverrideReference }}
{{- end }}
env:
- name: RABBIT_URL
value: "{{ tpl .Values.rabbitmq.url . }}"
- name: RABBIT_USER
value: "{{ .Values.rabbitmq.user }}"
{{- if .Values.rabbitmq.existingPasswordSecret }}
- name: RABBIT_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ .Values.rabbitmq.existingPasswordSecret }}"
key: {{ .Values.rabbitmq.existingPasswordSecretKey }}
{{- else }}
- name: RABBIT_PASSWORD
value: "{{ .Values.rabbitmq.password }}"
{{- end }}
- name: PUBLISH_PORT
value: "{{ .Values.service.internalPort }}"
- name: LOG_LEVEL
value: "{{ .Values.loglevel }}"
- name: RABBIT_CAPABILITIES
value: "{{ .Values.rabbitmq.capabilities }}"
- name: INCLUDE_QUEUES
value: "{{ .Values.rabbitmq.include_queues }}"
- name: INCLUDE_VHOST
value: "{{ .Values.rabbitmq.include_vhost }}"
- name: SKIP_QUEUES
value: "{{ .Values.rabbitmq.skip_queues }}"
- name: SKIPVERIFY
value: "{{ .Values.rabbitmq.skip_verify }}"
- name: SKIP_VHOST
value: "{{ .Values.rabbitmq.skip_vhost }}"
- name: RABBIT_EXPORTERS
value: "{{ .Values.rabbitmq.exporters }}"
- name: OUTPUT_FORMAT
value: "{{ .Values.rabbitmq.output_format }}"
- name: RABBIT_TIMEOUT
value: "{{ .Values.rabbitmq.timeout }}"
- name: MAX_QUEUES
value: "{{ .Values.rabbitmq.max_queues }}"
- name: EXCLUDE_METRICS
value: "{{ .Values.rabbitmq.excludeMetrics }}"
ports:
- containerPort: {{ .Values.service.internalPort }}
name: publish
Expand Down
3 changes: 2 additions & 1 deletion charts/prometheus-rabbitmq-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ affinity: {}

loglevel: info
rabbitmq:
# This field also accepts templated values
url: http://myrabbit:15672
user: guest
password: guest
Expand All @@ -52,6 +51,8 @@ rabbitmq:
timeout: 30
max_queues: 0
excludeMetrics: ""
# Enables overriding env vars using an external ConfigMap.
configMapOverrideReference: ""

## Additional labels to set in the Deployment object. Together with standard labels from
## the chart
Expand Down

0 comments on commit be0d387

Please sign in to comment.