diff --git a/charts/streams-app/templates/_helpers.tpl b/charts/streams-app/templates/_helpers.tpl index f1cbafc5..1e194955 100644 --- a/charts/streams-app/templates/_helpers.tpl +++ b/charts/streams-app/templates/_helpers.tpl @@ -29,15 +29,26 @@ Create chart name and version as used by the chart label. {{- end -}} {{/* -Helper function to add annotations to resources +Define default annotations from .Values.annotations. +This will be used across resources. */}} -{{- define "streams-app.annotations" -}} -{{- if or .Values.kafka.applicationId .Values.annotations }} +{{- define "streams-app.default-annotations" -}} +{{- if or .Values.annotations }} annotations: - {{- range $key, $value := .Values.annotations }} +{{- range $key, $value := .Values.annotations }} {{ $key | quote }}: {{ $value | quote }} - {{- end }} +{{- end }} +{{- end }} +{{- end }} +{{/* +Define annotations helper for Deployment. +Includes default annotations and conditionally adds consumerGroup. +Only includes annotations if there is content. +*/}} +{{- define "streams-app.deployment-annotations" -}} +{{- include "streams-app.default-annotations" . }} +{{- if .Values.kafka.applicationId }} {{- if and .Values.kafka.applicationId (not .Values.annotations.consumerGroup) }} consumerGroup: {{ .Values.kafka.applicationId | quote }} {{- end }} diff --git a/charts/streams-app/templates/configmap.yaml b/charts/streams-app/templates/configmap.yaml index e18b05b0..f041cc00 100644 --- a/charts/streams-app/templates/configmap.yaml +++ b/charts/streams-app/templates/configmap.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "streams-app.name" . }} - {{- include "streams-app.annotations" . | nindent 2 }} + {{- include "streams-app.default-annotations" . }} data: {{- range $key, $value := .Values.files }} {{ $key }}: {{ $value.content | quote }} diff --git a/charts/streams-app/templates/deployment.yaml b/charts/streams-app/templates/deployment.yaml index 2eb726bf..781ee057 100644 --- a/charts/streams-app/templates/deployment.yaml +++ b/charts/streams-app/templates/deployment.yaml @@ -15,7 +15,7 @@ kind: Deployment {{- end }} metadata: name: {{ template "streams-app.fullname" . }} - {{- include "streams-app.annotations" . | nindent 2 }} + {{- include "streams-app.deployment-annotations" . }} labels: app: {{ template "streams-app.name" . }} chart: {{ template "streams-app.chart" . }} diff --git a/charts/streams-app/templates/jmx-configmap.yaml b/charts/streams-app/templates/jmx-configmap.yaml index 15efe8e6..9315ddbf 100644 --- a/charts/streams-app/templates/jmx-configmap.yaml +++ b/charts/streams-app/templates/jmx-configmap.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "streams-app.name" . }}-jmx-configmap - {{- include "streams-app.annotations" . | nindent 2 }} + {{- include "streams-app.default-annotations" . }} labels: app: {{ template "streams-app.name" . }} chart: {{ template "streams-app.chart" . }} diff --git a/charts/streams-app/templates/scaled-object.yaml b/charts/streams-app/templates/scaled-object.yaml index 83e157ec..5130e562 100644 --- a/charts/streams-app/templates/scaled-object.yaml +++ b/charts/streams-app/templates/scaled-object.yaml @@ -7,7 +7,7 @@ apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: {{ template "streams-app.fullname" . }}-so - {{- include "streams-app.annotations" . | nindent 2 }} + {{- include "streams-app.default-annotations" . }} spec: scaleTargetRef: {{- if .Capabilities.APIVersions.Has "apps/v1" }} diff --git a/charts/streams-app/templates/secrets.yaml b/charts/streams-app/templates/secrets.yaml index bdb2cb0f..b63da1f1 100644 --- a/charts/streams-app/templates/secrets.yaml +++ b/charts/streams-app/templates/secrets.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ template "streams-app.fullname" . }} - {{- include "streams-app.annotations" . | nindent 2 }} + {{- include "streams-app.default-annotations" . }} type: Opaque data: {{- range $key, $value := .Values.secrets }} diff --git a/charts/streams-app/templates/service.yaml b/charts/streams-app/templates/service.yaml index 1b8a73b4..54ea4100 100644 --- a/charts/streams-app/templates/service.yaml +++ b/charts/streams-app/templates/service.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ template "streams-app.fullname" . }} - {{- include "streams-app.annotations" . | nindent 2 }} + {{- include "streams-app.default-annotations" . }} labels: app: {{ template "streams-app.name" . }} chart: {{ template "streams-app.chart" . }}