From 40b688936c5413a8f33727ea635960fad98bf219 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Wed, 24 Jan 2024 12:35:49 +0100 Subject: [PATCH] fix: config env, add secret env --- templates/_helpers.tpl | 5 ----- templates/deployment.yaml | 6 +++--- templates/ingress-traefik.yaml | 2 +- templates/secret-env.yaml | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 templates/secret-env.yaml diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index ee9fa92..f4b5b0c 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -10,11 +10,6 @@ {{ if .Values.routing.backend }}{{ .Values.appId }}{{ else }}{{ template "app.fullname" $ }}{{ end }} {{- end -}} - -{{- define "app.traefik.path" -}} - {{ if .Values.routing.path }} && PathPrefix(`{{ .Values.routing.path }}`){{ end }} -{{- end -}} - {{- define "app.routing.type" -}} {{ if .Values.global.routing.type }}{{ .Values.global.routing.type }}{{ else }}{{ .Values.routing.type }}{{ end }} {{- end -}} diff --git a/templates/deployment.yaml b/templates/deployment.yaml index d889089..abd7c5c 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -97,11 +97,11 @@ spec: {{- if .Values.envCustom }} {{- .Values.envCustom | toYaml | trim | nindent 10 }} {{- end }} - - {{- if or (.Values.global.inject_maps) (.Values.inject_maps) }} + envFrom: - configMapRef: name: {{ template "app.fullname" $ }}-env + {{- if or (.Values.global.inject_maps) (.Values.inject_maps) }} {{- $im := .Values.global.inject_maps -}} {{- if (.Values.inject_maps) }} {{- $im = concat .Values.inject_maps .Values.global.inject_maps | uniq -}} @@ -112,4 +112,4 @@ spec: name: {{ $map_name }} {{- end }} {{- end }} - {{- end }} \ No newline at end of file + {{- end }} \ No newline at end of file diff --git a/templates/ingress-traefik.yaml b/templates/ingress-traefik.yaml index 2b58f61..8da90f4 100644 --- a/templates/ingress-traefik.yaml +++ b/templates/ingress-traefik.yaml @@ -17,7 +17,7 @@ spec: {{ end }} routes: - kind: Rule - match: Host(`{{ include "app.ingress.host" . | trim }}`){{ include "app.traefik.path" $ }} + match: Host(`{{ include "app.ingress.host" . | trim }}`){{ if .Values.routing.path }} && PathPrefix(`{{ .Values.routing.path }}`){{ end }} {{ if .Values.routing.traefik.middleware.enabled }} middlewares: - name: {{ .Values.routing.traefik.middleware.name }} diff --git a/templates/secret-env.yaml b/templates/secret-env.yaml new file mode 100644 index 0000000..3b5b49a --- /dev/null +++ b/templates/secret-env.yaml @@ -0,0 +1,14 @@ +{{- if .Values.env_secrets }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "app.fullname" . }}-env + labels: + app: {{ include "app.fullname" . }} +{{ include "app.labels.common" $ | indent 4 }} +stringData: +{{- range $key,$val := .Values.env_secrets }} + {{ $key }}: {{ tpl ($val|toString) $ | quote }} +{{- end }} +type: Opaque +{{- end }}