From 7fa4bdb62a956a3fe0a20f9ac23b647027a7676d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20N=C3=A4gele?= Date: Mon, 22 Jan 2024 11:52:54 +0100 Subject: [PATCH] Issue 589: Add imagePullSecrets for Helm hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Change log description * Adds imagePullSecrets to the service accounts for the Helm hooks * Follows the same principle as the service account for the operator taking global imagePullSecrets into account ### Purpose of the change Fixes #589 ### What the code does Adds imagePullSecrets to the YAML for the ServiceAccounts for the Helm hooks. This is important when images are pulled from a private registry, e.g. an internal proxy, such as Artifactory, or when using custom images. ### How to verify it Render the templates using the following command: ```console helm template zookeeper charts/zookeeper-operator \ --show-only templates/post-install-upgrade-hooks.yaml \ --show-only templates/pre-delete-hooks.yaml \ --set hooks.serviceAccount.imagePullSecrets={'my-pull-secret'} ``` Signed-off-by: Reinhard Nägele # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # Date: Mon Jan 22 11:52:54 2024 +0100 # # On branch issue-589-pull-creds-for-hook # Your branch and 'origin/issue-589-pull-creds-for-hook' have diverged, # and have 1 and 1 different commits each, respectively. # # Changes to be committed: # modified: charts/zookeeper-operator/templates/post-install-upgrade-hooks.yaml # modified: charts/zookeeper-operator/templates/pre-delete-hooks.yaml # modified: charts/zookeeper-operator/values.yaml # --- .../templates/post-install-upgrade-hooks.yaml | 6 ++++++ charts/zookeeper-operator/templates/pre-delete-hooks.yaml | 6 ++++++ charts/zookeeper-operator/values.yaml | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/charts/zookeeper-operator/templates/post-install-upgrade-hooks.yaml b/charts/zookeeper-operator/templates/post-install-upgrade-hooks.yaml index bbbe41b86..cf65604da 100644 --- a/charts/zookeeper-operator/templates/post-install-upgrade-hooks.yaml +++ b/charts/zookeeper-operator/templates/post-install-upgrade-hooks.yaml @@ -51,6 +51,12 @@ metadata: "helm.sh/hook": post-install, post-upgrade "helm.sh/hook-weight": "1" "helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed +{{- if or .Values.global.imagePullSecrets .Values.hooks.serviceAccount.imagePullSecrets }} +imagePullSecrets: +{{- range (default .Values.global.imagePullSecrets .Values.hooks.serviceAccount.imagePullSecrets) }} + - name: {{ . }} +{{- end }} +{{- end }} --- diff --git a/charts/zookeeper-operator/templates/pre-delete-hooks.yaml b/charts/zookeeper-operator/templates/pre-delete-hooks.yaml index 77fa3895a..dc5f27e09 100644 --- a/charts/zookeeper-operator/templates/pre-delete-hooks.yaml +++ b/charts/zookeeper-operator/templates/pre-delete-hooks.yaml @@ -45,6 +45,12 @@ metadata: "helm.sh/hook": pre-delete "helm.sh/hook-weight": "1" "helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed +{{- if or .Values.global.imagePullSecrets .Values.hooks.serviceAccount.imagePullSecrets }} +imagePullSecrets: +{{- range (default .Values.global.imagePullSecrets .Values.hooks.serviceAccount.imagePullSecrets) }} + - name: {{ . }} +{{- end }} +{{- end }} --- diff --git a/charts/zookeeper-operator/values.yaml b/charts/zookeeper-operator/values.yaml index 3830f81f0..159b1685c 100644 --- a/charts/zookeeper-operator/values.yaml +++ b/charts/zookeeper-operator/values.yaml @@ -57,6 +57,10 @@ tolerations: [] annotations: {} hooks: + ## Optionally specify an array of imagePullSecrets. Will override the global parameter if set + serviceAccount: + imagePullSecrets: [] + backoffLimit: 10 image: repository: lachlanevenson/k8s-kubectl