From 412e33c308363d5b2f2d926dd944bd183abdfac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Rodr=C3=ADguez=20Hern=C3=A1ndez?= Date: Tue, 12 Mar 2019 11:54:51 +0100 Subject: [PATCH] [stable/redis] Add global 'imagePullSecrets' to overwrite any other existing one (#12068) * [stable/redis] Add global 'imagePullSecrets' to overwrite any other existing one Signed-off-by: Carlos Rodriguez Hernandez * Fix typo and add var to the README Signed-off-by: Carlos Rodriguez Hernandez * Fix typo in helpers Signed-off-by: Carlos Rodriguez Hernandez --- stable/redis/Chart.yaml | 2 +- stable/redis/README.md | 1 + stable/redis/templates/_helpers.tpl | 35 +++++++++++++++++++ .../redis/templates/metrics-deployment.yaml | 7 +--- .../templates/redis-master-statefulset.yaml | 7 +--- .../templates/redis-slave-deployment.yaml | 7 +--- stable/redis/values.yaml | 13 ++++--- 7 files changed, 48 insertions(+), 24 deletions(-) diff --git a/stable/redis/Chart.yaml b/stable/redis/Chart.yaml index 5c4165458e..9c434b8074 100644 --- a/stable/redis/Chart.yaml +++ b/stable/redis/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: redis -version: 6.1.4 +version: 6.2.0 appVersion: 4.0.13 description: Open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. keywords: diff --git a/stable/redis/README.md b/stable/redis/README.md index 749c3600cd..114b3271bb 100644 --- a/stable/redis/README.md +++ b/stable/redis/README.md @@ -90,6 +90,7 @@ The following table lists the configurable parameters of the Redis chart and the | Parameter | Description | Default | |--------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------| | `global.imageRegistry` | Global Docker image registry | `nil` | +| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | | `image.registry` | Redis Image registry | `docker.io` | | `image.repository` | Redis Image name | `bitnami/redis` | | `image.tag` | Redis Image tag | `{VERSION}` | diff --git a/stable/redis/templates/_helpers.tpl b/stable/redis/templates/_helpers.tpl index f39277e466..aacade4c7f 100644 --- a/stable/redis/templates/_helpers.tpl +++ b/stable/redis/templates/_helpers.tpl @@ -173,3 +173,38 @@ Return sysctl image {{- $tag := default "latest" .Values.sysctlImage.tag | toString -}} {{- printf "%s/%s:%s" $registryName .Values.sysctlImage.repository $tag -}} {{- end -}} + +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "redis.imagePullSecrets" -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic. +Also, we can not use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} +{{- if .Values.global.imagePullSecrets }} +imagePullSecrets: +{{- range .Values.global.imagePullSecrets }} + - name: {{ . }} +{{- end }} +{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- range .Values.metrics.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- range .Values.metrics.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- end -}} diff --git a/stable/redis/templates/metrics-deployment.yaml b/stable/redis/templates/metrics-deployment.yaml index bbf598062a..c9d9e542e8 100644 --- a/stable/redis/templates/metrics-deployment.yaml +++ b/stable/redis/templates/metrics-deployment.yaml @@ -30,12 +30,7 @@ spec: {{ toYaml .Values.metrics.podAnnotations | indent 8 }} {{- end }} spec: - {{- if .Values.metrics.image.pullSecrets }} - imagePullSecrets: - {{- range .Values.metrics.image.pullSecrets }} - - name: {{ . }} - {{- end}} - {{- end }} +{{- include "redis.imagePullSecrets" . | indent 6 }} {{- if .Values.metrics.nodeSelector }} nodeSelector: {{ toYaml .Values.metrics.nodeSelector | indent 8 }} diff --git a/stable/redis/templates/redis-master-statefulset.yaml b/stable/redis/templates/redis-master-statefulset.yaml index 1f87c0dba2..a2abb7671a 100644 --- a/stable/redis/templates/redis-master-statefulset.yaml +++ b/stable/redis/templates/redis-master-statefulset.yaml @@ -32,12 +32,7 @@ spec: {{ toYaml .Values.master.podAnnotations | indent 8 }} {{- end }} spec: - {{- if .Values.image.pullSecrets }} - imagePullSecrets: - {{- range .Values.image.pullSecrets }} - - name: {{ . }} - {{- end}} - {{- end}} +{{- include "redis.imagePullSecrets" . | indent 6 }} {{- if .Values.master.securityContext.enabled }} securityContext: fsGroup: {{ .Values.master.securityContext.fsGroup }} diff --git a/stable/redis/templates/redis-slave-deployment.yaml b/stable/redis/templates/redis-slave-deployment.yaml index 54bc9d9489..8239e5a5f1 100644 --- a/stable/redis/templates/redis-slave-deployment.yaml +++ b/stable/redis/templates/redis-slave-deployment.yaml @@ -39,12 +39,7 @@ spec: {{ toYaml (.Values.slave.podAnnotations | default .Values.master.podAnnotations) | indent 8 }} {{- end }} spec: - {{- if .Values.image.pullSecrets }} - imagePullSecrets: - {{- range .Values.image.pullSecrets }} - - name: {{ . }} - {{- end}} - {{- end}} +{{- include "redis.imagePullSecrets" . | indent 6 }} {{- /* Include master securityContext.fsGroup if slave securityContext.fsGroup not defined */ -}} {{- if (.Values.slave.securityContext | default .Values.master.securityContext) }} securityContext: diff --git a/stable/redis/values.yaml b/stable/redis/values.yaml index 33175865e3..048e58c018 100644 --- a/stable/redis/values.yaml +++ b/stable/redis/values.yaml @@ -1,8 +1,11 @@ -## Global Docker image registry -## Please, note that this will override the image registry for all the images, including dependencies, configured to use the global value +## Global Docker image parameters +## Please, note that this will override the image parameters, including dependencies, configured to use the global value +## Current available global Docker image parameters: imageRegistry and imagePullSecrets ## # global: -# imageRegistry: +# imageRegistry: myRegistryName +# imagePullSecrets: +# - myRegistryKeySecretName ## Bitnami Redis image version ## ref: https://hub.docker.com/r/bitnami/redis/tags/ @@ -24,7 +27,7 @@ image: ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ ## # pullSecrets: - # - myRegistrKeySecretName + # - myRegistryKeySecretName ## Cluster settings cluster: @@ -315,7 +318,7 @@ metrics: ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ ## # pullSecrets: - # - myRegistrKeySecretName + # - myRegistryKeySecretName service: type: ClusterIP