From 03511b65aab95ced33c1d256edccbf1d53fa8998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Rodr=C3=ADguez=20Hern=C3=A1ndez?= Date: Tue, 12 Mar 2019 10:19:01 +0100 Subject: [PATCH] [stable/drupal] Add global 'imagePullSecrets' to overwrite any other existing one (#12095) * [stable/drupal] 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/drupal/Chart.yaml | 2 +- stable/drupal/README.md | 1 + stable/drupal/templates/_helpers.tpl | 35 +++++++++++++++++++++++++ stable/drupal/templates/deployment.yaml | 7 +---- stable/drupal/values.yaml | 13 +++++---- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/stable/drupal/Chart.yaml b/stable/drupal/Chart.yaml index f5a86d8aaa..18424e9f02 100644 --- a/stable/drupal/Chart.yaml +++ b/stable/drupal/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: drupal -version: 3.0.8 +version: 3.1.0 appVersion: 8.6.10 description: One of the most versatile open source content management systems. keywords: diff --git a/stable/drupal/README.md b/stable/drupal/README.md index ab833f08f8..3af33135b0 100644 --- a/stable/drupal/README.md +++ b/stable/drupal/README.md @@ -50,6 +50,7 @@ The following table lists the configurable parameters of the Drupal chart and th | 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` | Drupal image registry | `docker.io` | | `image.repository` | Drupal Image name | `bitnami/drupal` | | `image.tag` | Drupal Image tag | `{VERSION}` | diff --git a/stable/drupal/templates/_helpers.tpl b/stable/drupal/templates/_helpers.tpl index 52d4f95770..63a94a3927 100644 --- a/stable/drupal/templates/_helpers.tpl +++ b/stable/drupal/templates/_helpers.tpl @@ -62,3 +62,38 @@ Return the proper image name (for the metrics image) {{- $tag := .Values.metrics.image.tag | toString -}} {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} {{- end -}} + +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "drupal.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/drupal/templates/deployment.yaml b/stable/drupal/templates/deployment.yaml index 05121a4698..83d8e6f834 100644 --- a/stable/drupal/templates/deployment.yaml +++ b/stable/drupal/templates/deployment.yaml @@ -29,12 +29,7 @@ spec: {{- end }} {{- end }} spec: - {{- if .Values.image.pullSecrets }} - imagePullSecrets: - {{- range .Values.image.pullSecrets }} - - name: {{ . }} - {{- end}} - {{- end }} +{{- include "drupal.imagePullSecrets" . | indent 6 }} hostAliases: - ip: "127.0.0.1" hostnames: diff --git a/stable/drupal/values.yaml b/stable/drupal/values.yaml index 4ca85f1464..28be4d98d7 100644 --- a/stable/drupal/values.yaml +++ b/stable/drupal/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 Drupal image version ## ref: https://hub.docker.com/r/bitnami/drupal/tags/ @@ -21,7 +24,7 @@ image: ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ ## # pullSecrets: - # - myRegistrKeySecretName + # - myRegistryKeySecretName ## Installation Profile ## ref: https://github.com/bitnami/bitnami-docker-drupal#configuration @@ -265,7 +268,7 @@ metrics: ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ ## # pullSecrets: - # - myRegistrKeySecretName + # - myRegistryKeySecretName ## Metrics exporter pod Annotation and Labels podAnnotations: prometheus.io/scrape: "true"