From 54c864b49042543c28567507aeaf6123ca9080cd Mon Sep 17 00:00:00 2001 From: Christopher Miller Date: Mon, 16 Dec 2024 22:10:52 -0800 Subject: [PATCH] fix constant restarts and keep job around in case it's needed --- charts/mega-media/Chart.yaml | 2 +- charts/mega-media/templates/arr-deployments.yaml | 2 +- .../mega-media/templates/helpers/_api_key_secret.tpl | 3 +++ .../mega-media/templates/helpers/_arr_deployment.tpl | 7 ++++++- charts/mega-media/templates/sabnzbd-deployment.yaml | 10 ++++++++-- charts/mega-media/templates/sync-prowlarr-hook.yaml | 3 +-- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/charts/mega-media/Chart.yaml b/charts/mega-media/Chart.yaml index df3a4a5..fd7f285 100644 --- a/charts/mega-media/Chart.yaml +++ b/charts/mega-media/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.1 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/mega-media/templates/arr-deployments.yaml b/charts/mega-media/templates/arr-deployments.yaml index 07c6592..6e1d082 100644 --- a/charts/mega-media/templates/arr-deployments.yaml +++ b/charts/mega-media/templates/arr-deployments.yaml @@ -3,7 +3,7 @@ {{- $apiKey := lower (randAlphaNum 32) -}} {{ if eq $tableSelect.enabled true }} -{{ template "mega-media.arr.deployment" (merge (dict "selected" $tableSelect "apiKey" $apiKey) $) }} +{{ template "mega-media.arr.deployment" (merge (dict "selected" $tableSelect) $) }} {{ template "mega-media.api-key-secret" (merge (dict "name" $tableSelect.name "apiKey" $apiKey) $) }} {{ template "mega-media.service" (merge (dict "name" $tableSelect.name "port" $tableSelect.port "targetPort" "http") $) }} {{- end }} diff --git a/charts/mega-media/templates/helpers/_api_key_secret.tpl b/charts/mega-media/templates/helpers/_api_key_secret.tpl index 637a8b6..675dd78 100644 --- a/charts/mega-media/templates/helpers/_api_key_secret.tpl +++ b/charts/mega-media/templates/helpers/_api_key_secret.tpl @@ -7,6 +7,9 @@ metadata: name: {{ include "mega-media.name" $nameInTable }}-api-key labels: {{- include "mega-media.labels" $nameInTable | nindent 4 }} + annotations: + helm.sh/hook: pre-install + helm.sh/hook-delete-policy: before-hook-creation data: key: {{ b64enc .apiKey }} {{- end }} diff --git a/charts/mega-media/templates/helpers/_arr_deployment.tpl b/charts/mega-media/templates/helpers/_arr_deployment.tpl index 365de3b..cd7ba91 100644 --- a/charts/mega-media/templates/helpers/_arr_deployment.tpl +++ b/charts/mega-media/templates/helpers/_arr_deployment.tpl @@ -65,7 +65,7 @@ spec: develop debug - {{ .apiKey }} + $(API_KEY) External {{ .Release.Name }} {{ $db_user }} @@ -82,6 +82,11 @@ spec: secretKeyRef: name: {{ $db_secret_name }} key: {{ $db_secret_key }} + - name: API_KEY + valueFrom: + secretKeyRef: + name: {{ include "mega-media.name" $nameInTable }}-api-key + key: key volumeMounts: - mountPath: /config name: config diff --git a/charts/mega-media/templates/sabnzbd-deployment.yaml b/charts/mega-media/templates/sabnzbd-deployment.yaml index e13bd1a..ec5e674 100644 --- a/charts/mega-media/templates/sabnzbd-deployment.yaml +++ b/charts/mega-media/templates/sabnzbd-deployment.yaml @@ -50,8 +50,8 @@ spec: __version__ = 19 __encoding__ = utf-8 [misc] - api_key = {{ $apiKey | quote }} - nzb_key = {{ $apiKey | quote }} + api_key = "$API_KEY" + nzb_key = "$API_KEY" " > /config/sabnzbd.ini && chmod 666 /config/sabnzbd.ini echo ' @@ -69,6 +69,12 @@ spec: name: config-file - mountPath: /config name: config + env: + - name: API_KEY + valueFrom: + secretKeyRef: + name: {{ include "mega-media.name" $contextWithName }}-api-key + key: key containers: - name: sabnzbd image: "{{ .image }}:{{ .tag }}" diff --git a/charts/mega-media/templates/sync-prowlarr-hook.yaml b/charts/mega-media/templates/sync-prowlarr-hook.yaml index f2cbc2e..dde39b7 100644 --- a/charts/mega-media/templates/sync-prowlarr-hook.yaml +++ b/charts/mega-media/templates/sync-prowlarr-hook.yaml @@ -12,9 +12,8 @@ metadata: labels: {{- include "mega-media.labels" $nameInTable | nindent 4 }} annotations: - "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook": post-install "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": hook-succeeded spec: template: metadata: