This is an automated email from the ASF dual-hosted git repository.

mmarshall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-helm-chart.git


The following commit(s) were added to refs/heads/master by this push:
     new 25f355e  Use appVersion as default tag for Pulsar images (#200)
25f355e is described below

commit 25f355e6e2af53b54f00cc7c53f03a065b0a5150
Author: Lari Hotari <[email protected]>
AuthorDate: Mon Oct 17 23:42:58 2022 +0300

    Use appVersion as default tag for Pulsar images (#200)
    
    Co-authored-by: Michael Marshall <[email protected]>
    
    ### Motivation
    
    There was a suggestion [in a dev mailing list 
discussion](https://lists.apache.org/thread/bgkvcyt1qq6h67p2k8xwp89xlncbqn3d) 
that the Helm chart's appVersion should be used as the default image tag.
    
    ### Additional context
    
    There are some limitations in Helm. It is not possible to set "appVersion" 
from the command line. There's in an open feature request 
https://github.com/helm/helm/issues/8194 to add such a feature to Helm.
    
    ### Modifications
    
    - change default values.yaml and set the tags for the images that use the 
Pulsar image to an empty value
    - add "defaultPulsarImageTag" to values.yaml
    - add a helper template "pulsar.imageFullName" that contains the logic to 
fall back to .Values.defaultPulsarImageTag and if it's not set, falling back to 
.Chart.AppVersion
    - use the helper template in all other templates that require the logic
---
 charts/pulsar/templates/_helpers.tpl               |  7 ++++++
 .../pulsar/templates/autorecovery-statefulset.yaml |  4 ++--
 .../templates/bookkeeper-cluster-initialize.yaml   |  4 ++--
 .../pulsar/templates/bookkeeper-statefulset.yaml   |  4 ++--
 charts/pulsar/templates/broker-configmap.yaml      |  4 ++--
 charts/pulsar/templates/broker-statefulset.yaml    |  6 ++---
 .../templates/function-worker-configmap.yaml       |  4 ++--
 charts/pulsar/templates/proxy-statefulset.yaml     |  6 ++---
 .../templates/pulsar-cluster-initialize.yaml       |  8 +++----
 charts/pulsar/templates/toolset-statefulset.yaml   |  2 +-
 charts/pulsar/templates/zookeeper-statefulset.yaml |  2 +-
 charts/pulsar/values.yaml                          | 27 +++++++++++++++-------
 12 files changed, 48 insertions(+), 30 deletions(-)

diff --git a/charts/pulsar/templates/_helpers.tpl 
b/charts/pulsar/templates/_helpers.tpl
index c1206c2..5ac9d23 100644
--- a/charts/pulsar/templates/_helpers.tpl
+++ b/charts/pulsar/templates/_helpers.tpl
@@ -102,3 +102,10 @@ imagePullSecrets:
 {{- end }}
 {{- end -}}
 {{- end }}
+
+{{/*
+Create full image name
+*/}}
+{{- define "pulsar.imageFullName" -}}
+{{- printf "%s:%s" .image.repository (.image.tag | default 
.root.Values.defaultPulsarImageTag | default .root.Chart.AppVersion) -}}
+{{- end -}}
diff --git a/charts/pulsar/templates/autorecovery-statefulset.yaml 
b/charts/pulsar/templates/autorecovery-statefulset.yaml
index 2b8a727..358afe5 100644
--- a/charts/pulsar/templates/autorecovery-statefulset.yaml
+++ b/charts/pulsar/templates/autorecovery-statefulset.yaml
@@ -111,7 +111,7 @@ spec:
       # This initContainer will wait for bookkeeper initnewcluster to complete
       # before deploying the bookies
       - name: pulsar-bookkeeper-verify-clusterid
-        image: "{{ .Values.images.autorecovery.repository }}:{{ 
.Values.images.autorecovery.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.autorecovery "root" .) }}"
         imagePullPolicy: {{ .Values.images.autorecovery.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -124,7 +124,7 @@ spec:
         {{- include "pulsar.autorecovery.certs.volumeMounts" . | nindent 8 }}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ 
.Values.autorecovery.component }}"
-        image: "{{ .Values.images.autorecovery.repository }}:{{ 
.Values.images.autorecovery.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.autorecovery "root" .) }}"
         imagePullPolicy: {{ .Values.images.autorecovery.pullPolicy }}
       {{- if .Values.autorecovery.resources }}
         resources:
diff --git a/charts/pulsar/templates/bookkeeper-cluster-initialize.yaml 
b/charts/pulsar/templates/bookkeeper-cluster-initialize.yaml
index cbdb52f..cedb648 100644
--- a/charts/pulsar/templates/bookkeeper-cluster-initialize.yaml
+++ b/charts/pulsar/templates/bookkeeper-cluster-initialize.yaml
@@ -39,7 +39,7 @@ spec:
     {{- end }}
       initContainers:
       - name: wait-zookeeper-ready
-        image: "{{ .Values.images.bookie.repository }}:{{ 
.Values.images.bookie.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.bookie "root" .) }}"
         imagePullPolicy: {{ .Values.images.bookie.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -55,7 +55,7 @@ spec:
             {{- end}}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ 
.Values.bookkeeper.component }}-init"
-        image: "{{ .Values.images.bookie.repository }}:{{ 
.Values.images.bookie.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.bookie "root" .) }}"
         imagePullPolicy: {{ .Values.images.bookie.pullPolicy }}
       {{- if .Values.bookkeeper.metadata.resources }}
         resources:
diff --git a/charts/pulsar/templates/bookkeeper-statefulset.yaml 
b/charts/pulsar/templates/bookkeeper-statefulset.yaml
index 43c4ba0..b3bf4d8 100644
--- a/charts/pulsar/templates/bookkeeper-statefulset.yaml
+++ b/charts/pulsar/templates/bookkeeper-statefulset.yaml
@@ -112,7 +112,7 @@ spec:
       # This initContainer will wait for bookkeeper initnewcluster to complete
       # before deploying the bookies
       - name: pulsar-bookkeeper-verify-clusterid
-        image: "{{ .Values.images.bookie.repository }}:{{ 
.Values.images.bookie.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.bookie "root" .) }}"
         imagePullPolicy: {{ .Values.images.bookie.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -130,7 +130,7 @@ spec:
         {{- include "pulsar.bookkeeper.certs.volumeMounts" . | nindent 8 }}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ 
.Values.bookkeeper.component }}"
-        image: "{{ .Values.images.bookie.repository }}:{{ 
.Values.images.bookie.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.bookie "root" .) }}"
         imagePullPolicy: {{ .Values.images.bookie.pullPolicy }}
         {{- if .Values.bookkeeper.probe.liveness.enabled }}
         livenessProbe:
diff --git a/charts/pulsar/templates/broker-configmap.yaml 
b/charts/pulsar/templates/broker-configmap.yaml
index 10077d4..b5278c9 100644
--- a/charts/pulsar/templates/broker-configmap.yaml
+++ b/charts/pulsar/templates/broker-configmap.yaml
@@ -58,7 +58,7 @@ data:
   # support version >= 2.5.0
   PF_functionRuntimeFactoryConfigs_pulsarRootDir: {{ template "pulsar.home" . 
}}
   PF_kubernetesContainerFactory_pulsarRootDir: {{ template "pulsar.home" . }}
-  PF_functionRuntimeFactoryConfigs_pulsarDockerImageName: "{{ 
.Values.images.functions.repository }}:{{ .Values.images.functions.tag }}"
+  PF_functionRuntimeFactoryConfigs_pulsarDockerImageName: "{{ template 
"pulsar.imageFullName" (dict "image" .Values.images.functions "root" .) }}"
   PF_functionRuntimeFactoryConfigs_submittingInsidePod: "true"
   PF_functionRuntimeFactoryConfigs_installUserCodeDependencies: "true"
   PF_functionRuntimeFactoryConfigs_jobNamespace: {{ template 
"pulsar.namespace" . }}
@@ -74,7 +74,7 @@ data:
   PF_functionRuntimeFactoryConfigs_changeConfigMap: "{{ template 
"pulsar.fullname" . }}-{{ .Values.functions.component }}-config"
   PF_functionRuntimeFactoryConfigs_changeConfigMapNamespace: {{ template 
"pulsar.namespace" . }}
   # support version < 2.5.0
-  PF_kubernetesContainerFactory_pulsarDockerImageName: "{{ 
.Values.images.functions.repository }}:{{ .Values.images.functions.tag }}"
+  PF_kubernetesContainerFactory_pulsarDockerImageName: "{{ template 
"pulsar.imageFullName" (dict "image" .Values.images.functions "root" .) }}"
   PF_kubernetesContainerFactory_submittingInsidePod: "true"
   PF_kubernetesContainerFactory_installUserCodeDependencies: "true"
   PF_kubernetesContainerFactory_jobNamespace: {{ template "pulsar.namespace" . 
}}
diff --git a/charts/pulsar/templates/broker-statefulset.yaml 
b/charts/pulsar/templates/broker-statefulset.yaml
index 333ac54..d969b66 100644
--- a/charts/pulsar/templates/broker-statefulset.yaml
+++ b/charts/pulsar/templates/broker-statefulset.yaml
@@ -106,7 +106,7 @@ spec:
       # This init container will wait for zookeeper to be ready before
       # deploying the bookies
       - name: wait-zookeeper-ready
-        image: "{{ .Values.images.broker.repository }}:{{ 
.Values.images.broker.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.broker "root" .) }}"
         imagePullPolicy: {{ .Values.images.broker.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -129,7 +129,7 @@ spec:
       # This init container will wait for bookkeeper to be ready before
       # deploying the broker
       - name: wait-bookkeeper-ready
-        image: "{{ .Values.images.broker.repository }}:{{ 
.Values.images.broker.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.broker "root" .) }}"
         imagePullPolicy: {{ .Values.images.broker.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -159,7 +159,7 @@ spec:
         {{- include "pulsar.broker.certs.volumeMounts" . | nindent 10 }}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component 
}}"
-        image: "{{ .Values.images.broker.repository }}:{{ 
.Values.images.broker.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.broker "root" .) }}"
         imagePullPolicy: {{ .Values.images.broker.pullPolicy }}
         {{- if .Values.broker.probe.liveness.enabled }}
         livenessProbe:
diff --git a/charts/pulsar/templates/function-worker-configmap.yaml 
b/charts/pulsar/templates/function-worker-configmap.yaml
index 186edad..653cc00 100644
--- a/charts/pulsar/templates/function-worker-configmap.yaml
+++ b/charts/pulsar/templates/function-worker-configmap.yaml
@@ -28,5 +28,5 @@ metadata:
     {{- include "pulsar.standardLabels" . | nindent 4 }}
     component: {{ .Values.functions.component }}
 data:
-  pulsarDockerImageName: "{{ .Values.images.functions.repository }}:{{ 
.Values.images.functions.tag }}"
-{{- end }}
\ No newline at end of file
+  pulsarDockerImageName: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.functions "root" .) }}"
+{{- end }}
diff --git a/charts/pulsar/templates/proxy-statefulset.yaml 
b/charts/pulsar/templates/proxy-statefulset.yaml
index a70811c..84b9c71 100644
--- a/charts/pulsar/templates/proxy-statefulset.yaml
+++ b/charts/pulsar/templates/proxy-statefulset.yaml
@@ -108,7 +108,7 @@ spec:
       # This init container will wait for zookeeper to be ready before
       # deploying the bookies
       - name: wait-zookeeper-ready
-        image: "{{ .Values.images.proxy.repository }}:{{ 
.Values.images.proxy.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.proxy "root" .) }}"
         imagePullPolicy: {{ .Values.images.proxy.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -125,7 +125,7 @@ spec:
       # This init container will wait for at least one broker to be ready 
before
       # deploying the proxy
       - name: wait-broker-ready
-        image: "{{ .Values.images.proxy.repository }}:{{ 
.Values.images.proxy.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.proxy "root" .) }}"
         imagePullPolicy: {{ .Values.images.proxy.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -139,7 +139,7 @@ spec:
             done;
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component 
}}"
-        image: "{{ .Values.images.proxy.repository }}:{{ 
.Values.images.proxy.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.proxy "root" .) }}"
         imagePullPolicy: {{ .Values.images.proxy.pullPolicy }}
         {{- if .Values.proxy.probe.liveness.enabled }}
         livenessProbe:
diff --git a/charts/pulsar/templates/pulsar-cluster-initialize.yaml 
b/charts/pulsar/templates/pulsar-cluster-initialize.yaml
index c9842d7..224d08a 100644
--- a/charts/pulsar/templates/pulsar-cluster-initialize.yaml
+++ b/charts/pulsar/templates/pulsar-cluster-initialize.yaml
@@ -38,7 +38,7 @@ spec:
       initContainers:
       {{- if .Values.pulsar_metadata.configurationStore }}
       - name: wait-cs-ready
-        image: "{{ .Values.pulsar_metadata.image.repository }}:{{ 
.Values.pulsar_metadata.image.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.pulsar_metadata.image "root" .) }}"
         imagePullPolicy: {{ .Values.pulsar_metadata.image.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -49,7 +49,7 @@ spec:
 
       {{- end }}
       - name: wait-zookeeper-ready
-        image: "{{ .Values.pulsar_metadata.image.repository }}:{{ 
.Values.pulsar_metadata.image.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.pulsar_metadata.image "root" .) }}"
         imagePullPolicy: {{ .Values.pulsar_metadata.image.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -66,7 +66,7 @@ spec:
       # This initContainer will wait for bookkeeper initnewcluster to complete
       # before initializing pulsar metadata
       - name: pulsar-bookkeeper-verify-clusterid
-        image: "{{ .Values.pulsar_metadata.image.repository }}:{{ 
.Values.pulsar_metadata.image.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.pulsar_metadata.image "root" .) }}"
         imagePullPolicy: {{ .Values.pulsar_metadata.image.pullPolicy }}
         command: ["sh", "-c"]
         args:
@@ -83,7 +83,7 @@ spec:
         {{- include "pulsar.toolset.certs.volumeMounts" . | nindent 8 }}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ 
.Values.pulsar_metadata.component }}"
-        image: "{{ .Values.pulsar_metadata.image.repository }}:{{ 
.Values.pulsar_metadata.image.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.pulsar_metadata.image "root" .) }}"
         imagePullPolicy: {{ .Values.pulsar_metadata.image.pullPolicy }}
       {{- if .Values.pulsar_metadata.resources }}
         resources:
diff --git a/charts/pulsar/templates/toolset-statefulset.yaml 
b/charts/pulsar/templates/toolset-statefulset.yaml
index 308e30f..e87c634 100644
--- a/charts/pulsar/templates/toolset-statefulset.yaml
+++ b/charts/pulsar/templates/toolset-statefulset.yaml
@@ -61,7 +61,7 @@ spec:
     {{- end}}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ .Values.toolset.component 
}}"
-        image: "{{ .Values.images.broker.repository }}:{{ 
.Values.images.broker.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.broker "root" .) }}"
         imagePullPolicy: {{ .Values.images.broker.pullPolicy }}
       {{- if .Values.toolset.resources }}
         resources:
diff --git a/charts/pulsar/templates/zookeeper-statefulset.yaml 
b/charts/pulsar/templates/zookeeper-statefulset.yaml
index 344ff8c..5590a40 100644
--- a/charts/pulsar/templates/zookeeper-statefulset.yaml
+++ b/charts/pulsar/templates/zookeeper-statefulset.yaml
@@ -107,7 +107,7 @@ spec:
       {{- end }}
       containers:
       - name: "{{ template "pulsar.fullname" . }}-{{ 
.Values.zookeeper.component }}"
-        image: "{{ .Values.images.zookeeper.repository }}:{{ 
.Values.images.zookeeper.tag }}"
+        image: "{{ template "pulsar.imageFullName" (dict "image" 
.Values.images.zookeeper "root" .) }}"
         imagePullPolicy: {{ .Values.images.zookeeper.pullPolicy }}
       {{- if .Values.zookeeper.resources }}
         resources:
diff --git a/charts/pulsar/values.yaml b/charts/pulsar/values.yaml
index 95bb18e..76b368d 100644
--- a/charts/pulsar/values.yaml
+++ b/charts/pulsar/values.yaml
@@ -157,33 +157,43 @@ extra:
   # Configure Kubernetes runtime for Functions
   functionsAsPods: false
 
+# default image tag for pulsar images
+# uses chart's appVersion when unspecified
+defaultPulsarImageTag:
+
 ## Images
 ##
 ## Control what images to use for each component
 images:
   zookeeper:
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
     pullPolicy: IfNotPresent
   bookie:
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
     pullPolicy: IfNotPresent
   autorecovery:
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
     pullPolicy: IfNotPresent
   broker:
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
     pullPolicy: IfNotPresent
   proxy:
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
     pullPolicy: IfNotPresent
   functions:
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
   prometheus:
     repository: prom/prometheus
     tag: v2.17.2
@@ -652,7 +662,8 @@ pulsar_metadata:
   image:
     # the image used for running `pulsar-cluster-initialize` job
     repository: apachepulsar/pulsar-all
-    tag: 2.9.3
+    # uses defaultPulsarImageTag when unspecified
+    tag:
     pullPolicy: IfNotPresent
   ## set an existing configuration store
   # configurationStore:
@@ -663,7 +674,7 @@ pulsar_metadata:
   # to use this, you should explicit set components.zookeeper to false
   #
   # userProvidedZookeepers: "zk01.example.com:2181,zk02.example.com:2181"
-  
+
   ## optional, you can specify where to run pulsar-cluster-initialize job
   # nodeSelector:
 

Reply via email to