Skip to content

Commit

Permalink
WIP: [prometheus-blackbox-exporter] sync daemonset features with depl…
Browse files Browse the repository at this point in the history
…oyment (#3700)

* sync daemonset features with deployment

This changes adds more features (e.g. extraVolumes) to the daemonset.

Signed-off-by: Tomáš Kukrál <[email protected]>

* use shared podspec for daemonset and deployment

Signed-off-by: Tomáš Kukrál <[email protected]>

---------

Signed-off-by: Tomáš Kukrál <[email protected]>
Co-authored-by: MH <[email protected]>
  • Loading branch information
tomkukral and zanhsieh authored Sep 27, 2023
1 parent 0665981 commit 2413df8
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 257 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.3.0
version: 8.4.0
appVersion: v0.24.0
home: https://github.com/prometheus/blackbox_exporter
sources:
Expand Down
145 changes: 145 additions & 0 deletions charts/prometheus-blackbox-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,148 @@ The image to use
{{- .Values.image.repository -}}:{{- .Values.image.tag | default .Chart.AppVersion -}}
{{- with .Values.image.digest -}}@{{ .}}{{- end -}}
{{- end -}}

{{/*
Define pod spec to be reused by highlevel resources (deployment, daemonset)
*/}}
{{- define "prometheus-blackbox-exporter.podSpec" -}}
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
serviceAccountName: {{ template "prometheus-blackbox-exporter.serviceAccountName" . }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.hostAliases }}
hostAliases:
{{- range .Values.hostAliases }}
- ip: {{ .ip }}
hostnames:
{{- range .hostNames }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
restartPolicy: {{ .Values.restartPolicy }}
{{- with .Values.priorityClassName }}
priorityClassName: "{{ . }}"
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{ toYaml . | indent 2 }}
{{- end }}
{{- with .Values.extraInitContainers }}
initContainers:
{{- toYaml . | indent 2 }}
{{- end }}
containers:
{{- with .Values.extraContainers }}
{{- toYaml . }}
{{- end }}
- name: blackbox-exporter
image: {{ include "prometheus-blackbox-exporter.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 4 }}
{{- end }}
env:
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
args:
{{- if .Values.config }}
{{- if .Values.configPath }}
- "--config.file={{ .Values.configPath }}"
{{- else }}
- "--config.file=/config/blackbox.yaml"
{{- end }}
{{- else }}
- "--config.file=/etc/blackbox_exporter/config.yml"
{{- end }}
{{- with .Values.extraArgs }}
{{ toYaml . | indent 2 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{ toYaml . | indent 4 }}
{{- end }}
ports:
- containerPort: {{ .Values.containerPort }}
name: http
livenessProbe:
{{- toYaml .Values.livenessProbe | trim | nindent 4 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | trim | nindent 4 }}
volumeMounts:
- mountPath: /config
name: config
{{- range .Values.extraConfigmapMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath | default "" }}
readOnly: {{ .readOnly }}
{{- end }}
{{- range .Values.extraSecretMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
readOnly: {{ .readOnly }}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 2 }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy | toString }}
{{- end }}
hostNetwork: {{ .Values.hostNetwork }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 2 }}
{{- end }}
volumes:
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes }}
{{- end }}
- name: config
{{- if .Values.secretConfig }}
secret:
secretName: {{ template "prometheus-blackbox-exporter.fullname" . }}
{{- else if .Values.configExistingSecretName }}
secret:
secretName: {{ .Values.configExistingSecretName }}
{{- else }}
configMap:
name: {{ template "prometheus-blackbox-exporter.fullname" . }}
{{- end }}
{{- range .Values.extraConfigmapMounts }}
- name: {{ .name }}
configMap:
name: {{ .configMap }}
defaultMode: {{ .defaultMode }}
{{- end }}
{{- range .Values.extraSecretMounts }}
- name: {{ .name }}
secret:
secretName: {{ .secretName }}
defaultMode: {{ .defaultMode }}
{{- end }}
{{- end -}}
121 changes: 1 addition & 120 deletions charts/prometheus-blackbox-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,124 +23,5 @@ spec:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "prometheus-blackbox-exporter.serviceAccountName" . }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 6 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.hostAliases }}
hostAliases:
{{- range .Values.hostAliases }}
- ip: {{ .ip }}
hostnames:
{{- range .hostNames }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
restartPolicy: {{ .Values.restartPolicy }}

{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
{{- if .Values.extraInitContainers }}
initContainers:
{{ toYaml .Values.extraInitContainers | indent 8 }}
{{- end }}
containers:
- name: blackbox-exporter
image: {{ include "prometheus-blackbox-exporter.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
args:
{{- if (or .Values.config .Values.configExistingSecretName) }}
{{- if .Values.configPath }}
- "--config.file={{ .Values.configPath }}"
{{- else }}
- "--config.file=/config/blackbox.yaml"
{{- end }}
{{- else }}
- "--config.file=/etc/blackbox_exporter/config.yml"
{{- end }}
{{- if .Values.extraArgs }}
{{ toYaml .Values.extraArgs | indent 12 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
ports:
- containerPort: {{ .Values.service.port }}
name: http
livenessProbe:
{{- toYaml .Values.livenessProbe | trim | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | trim | nindent 12 }}
volumeMounts:
- mountPath: /config
name: config
{{- range .Values.extraConfigmapMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath | default "" }}
readOnly: {{ .readOnly }}
{{- end }}
{{- range .Values.extraSecretMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
readOnly: {{ .readOnly }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy | toString }}
{{- end }}
hostNetwork: {{ .Values.hostNetwork }}
{{- if .Values.dnsConfig }}
dnsConfig:
{{- toYaml .Values.dnsConfig | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- if .Values.secretConfig }}
secret:
secretName: {{ template "prometheus-blackbox-exporter.fullname" . }}
{{- else if .Values.configExistingSecretName }}
secret:
secretName: {{ .Values.configExistingSecretName }}
{{- else }}
configMap:
name: {{ template "prometheus-blackbox-exporter.fullname" . }}
{{- end }}
{{- range .Values.extraConfigmapMounts }}
- name: {{ .name }}
configMap:
name: {{ .configMap }}
defaultMode: {{ .defaultMode }}
{{- end }}
{{- range .Values.extraSecretMounts }}
- name: {{ .name }}
secret:
secretName: {{ .secretName }}
defaultMode: {{ .defaultMode }}
{{- end }}
{{- include "prometheus-blackbox-exporter.podSpec" . | nindent 6 }}
{{- end }}
Loading

0 comments on commit 2413df8

Please sign in to comment.