From 2413df872e5807e1917fada2d13ad6bcf37c7b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kukr=C3=A1l?= Date: Wed, 27 Sep 2023 12:52:50 +0200 Subject: [PATCH] WIP: [prometheus-blackbox-exporter] sync daemonset features with deployment (#3700) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * sync daemonset features with deployment This changes adds more features (e.g. extraVolumes) to the daemonset. Signed-off-by: Tomáš Kukrál * use shared podspec for daemonset and deployment Signed-off-by: Tomáš Kukrál --------- Signed-off-by: Tomáš Kukrál Co-authored-by: MH --- .../prometheus-blackbox-exporter/Chart.yaml | 2 +- .../templates/_helpers.tpl | 145 ++++++++++++++++++ .../templates/daemonset.yaml | 121 +-------------- .../templates/deployment.yaml | 137 +---------------- 4 files changed, 148 insertions(+), 257 deletions(-) diff --git a/charts/prometheus-blackbox-exporter/Chart.yaml b/charts/prometheus-blackbox-exporter/Chart.yaml index c54ca67e0b2f..99ef4f326632 100644 --- a/charts/prometheus-blackbox-exporter/Chart.yaml +++ b/charts/prometheus-blackbox-exporter/Chart.yaml @@ -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: diff --git a/charts/prometheus-blackbox-exporter/templates/_helpers.tpl b/charts/prometheus-blackbox-exporter/templates/_helpers.tpl index 9cb28d28e2b9..072dfcc661ee 100644 --- a/charts/prometheus-blackbox-exporter/templates/_helpers.tpl +++ b/charts/prometheus-blackbox-exporter/templates/_helpers.tpl @@ -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 -}} diff --git a/charts/prometheus-blackbox-exporter/templates/daemonset.yaml b/charts/prometheus-blackbox-exporter/templates/daemonset.yaml index 7dad52ce3b43..c43513c8df97 100644 --- a/charts/prometheus-blackbox-exporter/templates/daemonset.yaml +++ b/charts/prometheus-blackbox-exporter/templates/daemonset.yaml @@ -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 }} diff --git a/charts/prometheus-blackbox-exporter/templates/deployment.yaml b/charts/prometheus-blackbox-exporter/templates/deployment.yaml index 79413b96e552..594bd8cbe8f8 100644 --- a/charts/prometheus-blackbox-exporter/templates/deployment.yaml +++ b/charts/prometheus-blackbox-exporter/templates/deployment.yaml @@ -26,140 +26,5 @@ spec: {{ toYaml .Values.podAnnotations | indent 8 }} {{- end }} spec: - automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} - serviceAccountName: {{ template "prometheus-blackbox-exporter.serviceAccountName" . }} - {{- with .Values.topologySpreadConstraints }} - topologySpreadConstraints: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- 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 }} - securityContext: -{{ toYaml .Values.podSecurityContext | indent 8 }} - {{- if .Values.extraInitContainers }} - initContainers: -{{ toYaml .Values.extraInitContainers | indent 8 }} - {{- end }} - containers: - {{- if .Values.extraContainers }} -{{ toYaml .Values.extraContainers | indent 8 }} - {{- end }} - - 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 .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 }} - {{- if .Values.extraArgs }} -{{ toYaml .Values.extraArgs | indent 12 }} - {{- end }} - resources: -{{ toYaml .Values.resources | indent 12 }} - ports: - - containerPort: {{ .Values.containerPort }} - 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.extraVolumeMounts }} -{{ toYaml .Values.extraVolumeMounts | indent 12 }} - {{- end }} -{{- if .Values.dnsPolicy }} - dnsPolicy: {{ .Values.dnsPolicy | toString }} -{{- end }} - hostNetwork: {{ .Values.hostNetwork }} -{{- if .Values.dnsConfig }} - dnsConfig: - {{- toYaml .Values.dnsConfig | nindent 8 }} -{{- end }} - volumes: - {{- if .Values.extraVolumes }} -{{ toYaml .Values.extraVolumes | indent 8 }} - {{- 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 }} + {{- include "prometheus-blackbox-exporter.podSpec" . | nindent 6 }} {{- end }}