From f098ffc07fe9a350e827c8f3396f3afc2b41df81 Mon Sep 17 00:00:00 2001 From: Ryan Connell <7585908+RyanConnell@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:13:36 +0000 Subject: [PATCH] helm: Allow secrets to be used for environment variables --- helm/templates/cron.yaml | 18 ++++++++++++++++-- helm/values.yaml | 16 ++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/helm/templates/cron.yaml b/helm/templates/cron.yaml index 57c61c6..a51ff6f 100644 --- a/helm/templates/cron.yaml +++ b/helm/templates/cron.yaml @@ -17,9 +17,23 @@ spec: - /bin/concert-watcher scan --api-key $TICKETMASTER_API_KEY --artist-file /config/artists --discord-webhook-url $DISCORD_WEBHOOK_URL --ticketmaster-config /config/ticketmaster.yaml --diff --diff-file /data/previous-ids --include-partial-match env: - name: "TICKETMASTER_API_KEY" - value: "{{ .Values.ticketmaster.apiKey }}" + {{- if .Values.ticketmaster.apiKey.secret }} + valueFrom: + secretKeyRef: + name: "{{ .Values.ticketmaster.apiKey.secret.name }}" + key: "{{ .Values.ticketmaster.apiKey.secret.key }}" + {{- else }} + value: "{{ .Values.ticketmaster.apiKey.value }}" + {{- end }} - name: "DISCORD_WEBHOOK_URL" - value: "{{ .Values.discord.webhookURL }}" + {{- if .Values.discord.webhookURL.secret }} + valueFrom: + secretKeyRef: + name: "{{ .Values.discord.webhookURL.secret.name }}" + key: "{{ .Values.discord.webhookURL.secret.key }}" + {{- else }} + value: "{{ .Values.discord.webhookURL.value }}" + {{- end }} volumeMounts: - name: config-map mountPath: /config diff --git a/helm/values.yaml b/helm/values.yaml index 37d5680..56e718a 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -7,10 +7,22 @@ image: discord: # Add a webhook URL to enable discord notifications. - webhookURL: "" + webhookURL: + # If 'secret' is provided we will use that to populate DISCORD_WEBHOOK_URL. + secret: + name: concert-watcher + key: discord-webhook-url + # If 'secret' is not provided we can use 'value' instead. + value: "{DISCORD_API_KEY_GOES_HERE}" ticketmaster: - apiKey: "{TICKETMASTER_API_KEY_GOES_HERE}" + apiKey: + # If 'secret' is provided we will use that to populate TICKETMASTER_API_KEY. + secret: + name: concert-watcher + key: ticketmaster-api-key + # If 'secret' is not provided we can use 'value' instead. + value: "{TICKETMASTER_API_KEY_GOES_HERE}" storage: className: nfs-client