From 085a68c60c20ab7c1b2868404aef72027e9279e2 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 25 Nov 2024 23:24:04 +0100 Subject: [PATCH] revert(README): adapt warning blockquote This reverts commit 98fe8fe2a401b0230747466d85b0ea179768c712. --- README.md | 4 +- .../_deployment.tpl | 17 ++-- .../deployment.yaml | 5 -- unittests/deployment/deployment.yaml | 79 ------------------- 4 files changed, 7 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 703098e..8031c1a 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,8 @@ The first example shows how to deploy the metric exporter with TLS encryption. T certification will be skipped by Prometheus. > [!WARNING] -> The secret `prometheus-postgresql-exporter-http` containing the TLS certificate is already present. The keys `ca.crt`, -> `tls.key` and `tls.crt` of the secret can be mounted into the container filesystem for TLS authentication / encryption. +> A TLS secret with the name `prometheus-postgresql-exporter-http` containing a `ca.crt`, `tls.key` and `tls.crt` is +> already present. ```bash helm install prometheus-exporters/prometheus-postgres-exporter prometheus-postgres-exporter \ diff --git a/templates/prometheus-postgres-exporter/_deployment.tpl b/templates/prometheus-postgres-exporter/_deployment.tpl index 92b0798..55da6a2 100644 --- a/templates/prometheus-postgres-exporter/_deployment.tpl +++ b/templates/prometheus-postgres-exporter/_deployment.tpl @@ -50,9 +50,10 @@ {{- end }} {{/* volumeMounts */}} + {{- define "prometheus-postgres-exporter.deployment.volumeMounts" -}} {{- $volumeMounts := dict "volumeMounts" (.Values.deployment.postgresExporter.volumeMounts | default (list) ) }} -{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "config.d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }} +{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "exporter-config" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }} {{ toYaml $volumeMounts }} {{- end -}} @@ -60,18 +61,10 @@ {{- define "prometheus-postgres-exporter.deployment.volumes" -}} {{- $volumes := dict "volumes" (.Values.deployment.volumes | default (list) ) }} - -{{- if and (not .Values.config.exporterConfig.existingSecret.enabled) (not .Values.config.webConfig.existingSecret.enabled) (not .Values.config.webConfig.secret.webConfig) }} +{{- $secretName := .Values.config.exporterConfig.existingSecret.secretName -}} +{{- if not .Values.config.exporterConfig.existingSecret.enabled }} {{- $secretName = printf "%s-exporter-config" (include "prometheus-postgres-exporter.fullname" . ) }} -{{- $volumes = merge $volumes (dict "volumes" (list (dict "name" "config.d" "secret" (dict "secretName" $secretName)))) }} -{{- end }} - -{{- if and (not .Values.config.exporterConfig.existingSecret.enabled) (or .Values.config.webConfig.existingSecret.enabled .Values.config.webConfig.secret.webConfig) }} -{{- $exporterConfigSecretName = .Values.config.exporterConfig.existingSecret.secretName }} -{{- $webConfigSecretName = .Values.config.webConfig.existingSecret.secretName }} - -{{- if -}} - {{- end }} +{{- $volumes = merge $volumes (dict "volumes" (list (dict "name" "exporter-config" "secret" (dict "secretName" $secretName)))) }} {{ toYaml $volumes }} {{- end -}} \ No newline at end of file diff --git a/templates/prometheus-postgres-exporter/deployment.yaml b/templates/prometheus-postgres-exporter/deployment.yaml index b97faa5..60b3390 100644 --- a/templates/prometheus-postgres-exporter/deployment.yaml +++ b/templates/prometheus-postgres-exporter/deployment.yaml @@ -23,12 +23,7 @@ spec: containers: - name: postgres-exporter args: - {{- if or .Values.config.exporterConfig.existingSecret.enabled .Values.config.exporterConfig.secret.exporterConfig }} - "--config.file=/etc/prometheus-postgres-exporter/config.d/exporterConfig.yaml" - {{- end }} - {{- if or .Values.config.webConfig.existingSecret.enabled .Values.config.webConfig.secret.webConfig }} - - "--web.config.file=/etc/prometheus-postgres-exporter/config.d/webConfig.yaml" - {{- end }} - "--web.listen-address=:9187" {{- range .Values.deployment.postgresExporter.args }} - {{ . | quote }} diff --git a/unittests/deployment/deployment.yaml b/unittests/deployment/deployment.yaml index 34b5f8b..8872f5f 100644 --- a/unittests/deployment/deployment.yaml +++ b/unittests/deployment/deployment.yaml @@ -43,82 +43,3 @@ tests: content: secretRef: name: custom-database-secret - -- it: Test mount exporterConfig.yaml - set: - config.exporterConfig.existingSecret.enabled: false - config.exporterConfig.secret.exporterConfig: - foo: bar - asserts: - - equal: - path: spec.template.spec.containers[0].args - value: - - --config.file=/etc/prometheus-postgres-exporter/config.d/exporterConfig.yaml - - --web.listen-address=:9187 - - contains: - path: spec.template.spec.containers[0].volumeMounts - content: - mountPath: /etc/prometheus-postgres-exporter/config.d - name: config.d - - contains: - path: spec.template.spec.volumes - content: - name: config.d - secret: - secretName: prometheus-postgres-exporter-unittest-exporter-config - -- it: Test mount exporterConfig.yaml from secret - set: - config.exporterConfig.existingSecret.enabled: true - config.exporterConfig.existingSecret.secretName: my-secret - asserts: - - equal: - path: spec.template.spec.containers[0].args - value: - - --config.file=/etc/prometheus-postgres-exporter/config.d/exporterConfig.yaml - - --web.listen-address=:9187 - - contains: - path: spec.template.spec.containers[0].volumeMounts - content: - mountPath: /etc/prometheus-postgres-exporter/config.d - name: config.d - - contains: - path: spec.template.spec.volumes - content: - name: config.d - secret: - secretName: my-secret - -- it: Test mount webConfig.yaml - set: - config.webConfig.existingSecret.enabled: false - config.webConfig.secret.webConfig: - foo: bar - asserts: - - equal: - path: spec.template.spec.containers[0].args - value: - - --web.config.file=/etc/prometheus-postgres-exporter/config.d/webConfig.yaml - - --web.listen-address=:9187 - - contains: - path: spec.template.spec.containers[0].volumeMounts - content: - mountPath: /etc/prometheus-postgres-exporter/config.d - name: config.d - - contains: - path: spec.template.spec.volumes - content: - name: config.d - secret: - secretName: prometheus-postgres-exporter-unittest-web-config - -# - it: Test mount webConfig.yaml from secret -# set: -# config.webConfig.existingSecret.enabled: true -# config.webConfig.existingSecret.secretName: my-secret -# asserts: -# - equal: -# path: spec.template.spec.containers[0].args -# value: -# - --web.config.file=/etc/prometheus-postgres-exporter/config.d/webConfig.yaml -# - --web.listen-address=:9187 \ No newline at end of file