From 7a6535fc25321d96bd7e517ea2ced252fe34e9d2 Mon Sep 17 00:00:00 2001 From: miguelaeh Date: Tue, 2 Jul 2019 11:37:42 +0200 Subject: [PATCH] Add template for image on Spark Chart --- bitnami/spark/Chart.yaml | 2 +- bitnami/spark/templates/_helpers.tpl | 24 +++++++++++++++++++ .../spark/templates/statefulset-master.yaml | 2 +- .../spark/templates/statefulset-worker.yaml | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/bitnami/spark/Chart.yaml b/bitnami/spark/Chart.yaml index acaff044b..55fa989a4 100644 --- a/bitnami/spark/Chart.yaml +++ b/bitnami/spark/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 2.4.3 description: Spark is a fast and general-purpose cluster computing system. name: spark -version: 0.0.1 +version: 0.0.2 icon: https://bitnami.com/assets/stacks/spark/img/spark-stack-220x234-1ea65541e9e427ca5b93300e61d4778576c7f679ae02addb86a2641b0ca70476.png home: https://spark.apache.org/ sources: diff --git a/bitnami/spark/templates/_helpers.tpl b/bitnami/spark/templates/_helpers.tpl index 4d50f742b..9a8738934 100644 --- a/bitnami/spark/templates/_helpers.tpl +++ b/bitnami/spark/templates/_helpers.tpl @@ -6,6 +6,30 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Return the proper Spark image name +*/}} +{{- define "spark.image" -}} +{{- $registryName := .Values.image.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- $tag := .Values.image.tag | toString -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. +Also, we can't use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} + {{- if .Values.global.imageRegistry }} + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} + {{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} + {{- end -}} +{{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} +{{- end -}} + + {{- /* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). diff --git a/bitnami/spark/templates/statefulset-master.yaml b/bitnami/spark/templates/statefulset-master.yaml index 245816627..845d17279 100644 --- a/bitnami/spark/templates/statefulset-master.yaml +++ b/bitnami/spark/templates/statefulset-master.yaml @@ -44,7 +44,7 @@ spec: {{- end }} containers: - name: spark-master - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "spark.image" . }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http diff --git a/bitnami/spark/templates/statefulset-worker.yaml b/bitnami/spark/templates/statefulset-worker.yaml index 8d556fc9f..515905aa9 100644 --- a/bitnami/spark/templates/statefulset-worker.yaml +++ b/bitnami/spark/templates/statefulset-worker.yaml @@ -44,7 +44,7 @@ spec: {{- end }} containers: - name: spark-worker - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "spark.image" . }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http