Skip to content

Commit

Permalink
[prometheus-blackbox-exporter] Integrate config-reloader
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Jan 16, 2024
1 parent 996078e commit 9130023
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-blackbox-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: Prometheus Blackbox Exporter
name: prometheus-blackbox-exporter
version: 8.8.0
version: 8.9.0
appVersion: v0.24.0
home: https://github.com/prometheus/blackbox_exporter
sources:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
configReloader:
enabled: true
41 changes: 41 additions & 0 deletions charts/prometheus-blackbox-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ The image to use
{{- with .Values.image.digest -}}@{{ .}}{{- end -}}
{{- end -}}

{{/*
The image to use
*/}}
{{- define "prometheus-blackbox-exporter.config-reloader.image" -}}
{{- with (.Values.global.imageRegistry | default .Values.configReloader.image.registry) -}}{{ . }}/{{- end }}
{{- .Values.configReloader.image.repository -}}:{{- .Values.configReloader.image.tag -}}
{{- with .Values.configReloader.image.digest -}}@{{ .}}{{- end -}}
{{- end -}}

{{/*
Define pod spec to be reused by highlevel resources (deployment, daemonset)
*/}}
Expand Down Expand Up @@ -165,6 +174,38 @@ containers:
{{- toYaml . }}
{{- end -}}
{{- end }}

{{- if .Values.configReloader.enabled }}
- name: config-reloader
image: {{ include "prometheus-blackbox-exporter.config-reloader.image" . }}
imagePullPolicy: {{ .Values.configReloader.image.pullPolicy }}
args:
- --config-file={{ .Values.configPath | default "/config/blackbox.yaml" }}
- --watch-interval={{ .Values.configReloader.config.watchInterval }}
- --reload-url=http://127.0.0.1:{{ .Values.containerPort }}/-/reload
- --listen-address=:{{ .Values.configReloader.containerPort }}
- --log-format={{ .Values.configReloader.config.logFormat }}
- --log-level={{ .Values.configReloader.config.logLevel }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 4 }}
{{- end }}
ports:
- name: reloader-web
containerPort: {{ .Values.configReloader.containerPort }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.configReloader.livenessProbe | nindent 4 }}
readinessProbe:
{{- toYaml .Values.configReloader.readinessProbe | nindent 4 }}
volumeMounts:
- mountPath: /config
name: config
{{- with .Values.configReloader.securityContext }}
securityContext:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
- name: blackbox-exporter
image: {{ include "prometheus-blackbox-exporter.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand Down
4 changes: 4 additions & 0 deletions charts/prometheus-blackbox-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ spec:
{{- if .Values.pod.labels }}
{{ toYaml .Values.pod.labels | indent 8 }}
{{- end }}
{{- if or (not .Values.configReloader.enabled) .Values.podAnnotations }}
annotations:
{{- if not .Values.configReloader.enabled }}
checksum/config: {{ toYaml .Values.config | sha256sum }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
{{- end }}
spec:
{{- include "prometheus-blackbox-exporter.podSpec" . | nindent 6 }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/prometheus-blackbox-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ spec:
{{- if .Values.pod.labels }}
{{ toYaml .Values.pod.labels | indent 8 }}
{{- end }}
{{- if or (not .Values.configReloader.enabled) .Values.podAnnotations }}
annotations:
{{- if not .Values.configReloader.enabled }}
checksum/config: {{ toYaml .Values.config | sha256sum }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
{{- end }}
spec:
{{- include "prometheus-blackbox-exporter.podSpec" . | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ spec:
interval: {{ .Values.serviceMonitor.selfMonitor.interval }}
scrapeTimeout: {{ .Values.serviceMonitor.selfMonitor.scrapeTimeout }}
scheme: http

{{- if .Values.serviceMonitor.selfMonitor.additionalRelabeling }}
{{- if .Values.serviceMonitor.selfMonitor.additionalRelabeling }}
relabelings:
{{ toYaml .Values.serviceMonitor.selfMonitor.additionalRelabeling | indent 6 }}
{{- end }}
{{- toYaml .Values.serviceMonitor.selfMonitor.additionalRelabeling | nindent 6 }}
{{- end }}
{{- if .Values.configReloader.enabled }}
- path: {{ .Values.configReloader.serviceMonitor.selfMonitor.path }}
interval: {{ .Values.configReloader.serviceMonitor.selfMonitor.interval }}
scrapeTimeout: {{ .Values.configReloader.serviceMonitor.selfMonitor.scrapeTimeout }}
scheme: http
{{- if .Values.configReloader.serviceMonitor.selfMonitor.additionalRelabeling }}
relabelings:
{{- toYaml .Values.configReloader.serviceMonitor.selfMonitor.additionalRelabeling | indent 6 }}
{{- end }}
{{- end }}
jobLabel: "{{ .Release.Name }}"
selector:
matchLabels:
{{- include "prometheus-blackbox-exporter.selectorLabels" $ | nindent 6 }}
namespaceSelector:
matchNames:
- {{ template "prometheus-blackbox-exporter.namespace" $ }}

{{- end }}
6 changes: 6 additions & 0 deletions charts/prometheus-blackbox-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ spec:
targetPort: http
protocol: TCP
name: http
{{ if .Values.configReloader.enabled }}
- port: {{ .Values.configReloader.service.port }}
targetPort: reloader-web
protocol: TCP
name: reloader-web
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
Expand Down
47 changes: 47 additions & 0 deletions charts/prometheus-blackbox-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,50 @@ verticalPodAutoscaler:
# Specifies whether recommended updates are applied when a Pod is started and whether recommended updates
# are applied during the life of a Pod. Possible values are "Off", "Initial", "Recreate", and "Auto".
updateMode: Auto

configReloader:
enabled: false
containerPort: 8080
config:
logFormat: logfmt
logLevel: info
watchInterval: 1m
image:
registry: quay.io
repository: prometheus-operator/prometheus-config-reloader
tag: "v0.70.0"
pullPolicy: IfNotPresent
digest: ""
securityContext:
runAsUser: 1000
runAsGroup: 1000
readOnlyRootFilesystem: true
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
resources:
limits:
memory: 50Mi
requests:
cpu: 10m
memory: 20Mi
livenessProbe:
httpGet:
path: /healthz
port: reloader-web
scheme: HTTP
readinessProbe:
httpGet:
path: /healthz
port: reloader-web
scheme: HTTP
service:
port: 8080
serviceMonitor:
selfMonitor:
additionalMetricsRelabels: {}
additionalRelabeling: []
path: /metrics
interval: 30s
scrapeTimeout: 30s

0 comments on commit 9130023

Please sign in to comment.