fix(deployment,secrets): deploy always the web-config secret
This commit is contained in:
parent
6c30756f8d
commit
7b98e68b03
@ -53,7 +53,7 @@
|
||||
|
||||
{{- define "prometheus-postgres-exporter.deployment.volumeMounts" -}}
|
||||
{{- $volumeMounts := dict "volumeMounts" (.Values.deployment.postgresExporter.volumeMounts | default (list) ) }}
|
||||
{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "exporter-config" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }}
|
||||
{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "config.d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }}
|
||||
{{ toYaml $volumeMounts }}
|
||||
{{- end -}}
|
||||
|
||||
@ -61,10 +61,19 @@
|
||||
|
||||
{{- define "prometheus-postgres-exporter.deployment.volumes" -}}
|
||||
{{- $volumes := dict "volumes" (.Values.deployment.volumes | default (list) ) }}
|
||||
{{- $secretName := .Values.config.exporterConfig.existingSecret.secretName -}}
|
||||
|
||||
{{- $exporterSecretName := .Values.config.exporterConfig.existingSecret.secretName -}}
|
||||
{{- if not .Values.config.exporterConfig.existingSecret.enabled }}
|
||||
{{- $secretName = printf "%s-exporter-config" (include "prometheus-postgres-exporter.fullname" . ) }}
|
||||
{{- $exporterSecretName = printf "%s-exporter-config" (include "prometheus-postgres-exporter.fullname" . ) }}
|
||||
{{- end }}
|
||||
{{- $volumes = merge $volumes (dict "volumes" (list (dict "name" "exporter-config" "secret" (dict "secretName" $secretName)))) }}
|
||||
|
||||
{{- $webConfigSecretName := .Values.config.webConfig.existingSecret.secretName -}}
|
||||
{{- if not .Values.config.webConfig.existingSecret.enabled }}
|
||||
{{- $webConfigSecretName = printf "%s-web-config" (include "prometheus-postgres-exporter.fullname" . ) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $volumes = merge $volumes (dict "volumes" (list (dict "name" "config.d" "projected" (dict "defaultMode" "0444" "sources" (list (dict "secret" (dict "name" $exporterSecretName)) (dict "secret" (dict "name" $webConfigSecretName))))))) }}
|
||||
|
||||
{{ toYaml $volumes }}
|
||||
|
||||
{{- end -}}
|
@ -1,4 +1,4 @@
|
||||
{{- if and (not (.Values.config.webConfig.existingSecret.enabled)) .Values.config.webConfig.secret.webConfig }}
|
||||
{{- if not .Values.config.webConfig.existingSecret.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
|
@ -38,6 +38,22 @@ tests:
|
||||
- --config.file=/etc/prometheus-postgres-exporter/config.d/exporterConfig.yaml
|
||||
- --web.config.file=/etc/prometheus-postgres-exporter/config.d/web-config.yaml
|
||||
- --web.listen-address=:9187
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
name: config.d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config.d
|
||||
projected:
|
||||
defaultMode: "0444"
|
||||
sources:
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-exporter-config
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-web-config
|
||||
|
||||
- it: Test additional arguments
|
||||
set:
|
||||
@ -64,3 +80,47 @@ tests:
|
||||
content:
|
||||
secretRef:
|
||||
name: custom-database-secret
|
||||
|
||||
- it: Test exporterConfig with own secret
|
||||
set:
|
||||
config.exporterConfig.existingSecret.enabled: true
|
||||
config.exporterConfig.existingSecret.secretName: exporter-config-secret
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
name: config.d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config.d
|
||||
projected:
|
||||
defaultMode: "0444"
|
||||
sources:
|
||||
- secret:
|
||||
name: exporter-config-secret
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-web-config
|
||||
|
||||
- it: Test webConfig with own secret
|
||||
set:
|
||||
config.webConfig.existingSecret.enabled: true
|
||||
config.webConfig.existingSecret.secretName: web-config-secret
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
name: config.d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config.d
|
||||
projected:
|
||||
defaultMode: "0444"
|
||||
sources:
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-exporter-config
|
||||
- secret:
|
||||
name: web-config-secret
|
||||
|
@ -8,27 +8,7 @@ release:
|
||||
templates:
|
||||
- templates/prometheus-postgres-exporter/secretWebConfig.yaml
|
||||
tests:
|
||||
- it: Skip rendering by using existing secret.
|
||||
set:
|
||||
config.webConfig.existingSecret.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: Skip rendering when no webConfig.yaml is defined.
|
||||
set:
|
||||
config.webConfig.existingSecret.enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: Rendering database secret.
|
||||
set:
|
||||
config.webConfig.secret.webConfig:
|
||||
tls_server_config:
|
||||
cert_file: /path/to/cert.pem
|
||||
client_ca_file: /path/to/ca.pem
|
||||
key_file: /path/to/key.pem
|
||||
- it: Rendering default secret.
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
@ -47,6 +27,19 @@ tests:
|
||||
app.kubernetes.io/name: prometheus-postgres-exporter
|
||||
app.kubernetes.io/version: 0.1.0
|
||||
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
||||
- equal:
|
||||
path: stringData["webConfig.yaml"]
|
||||
value: |
|
||||
{}
|
||||
|
||||
- it: Rendering custom webconfig.
|
||||
set:
|
||||
config.webConfig.secret.webConfig:
|
||||
tls_server_config:
|
||||
cert_file: /path/to/cert.pem
|
||||
client_ca_file: /path/to/ca.pem
|
||||
key_file: /path/to/key.pem
|
||||
asserts:
|
||||
- equal:
|
||||
path: stringData["webConfig.yaml"]
|
||||
value: |
|
||||
|
Loading…
Reference in New Issue
Block a user