Suppose we have the following in, say, _helpers.tpl:
{{- define "app.selectorLabels" -}}
app.kubernetes.io/name: app
app.kubernetes.io/instance: instance
{{- end }}
{{- define "app.component.selectorLabels" -}}
{{ include "app.selectorLabels" . }}
app.kubernetes.io/component: component
{{- end }}
{{- define "app.labels" -}}
foo: bar
{{ include "app.selectorLabels" . }}
{{- end }}
{{- define "app.component.labels" -}}
{{ include "app.labels" . }}
{{ include "app.component.selectorLabels" . }}
{{- end }}
Now the app.component.labels named template - used , say, with include somewhere in svc.yaml or whatever - will contain the content of app.selectorLabels twice and will render as the following:
foo: bar
app.kubernetes.io/name: app
app.kubernetes.io/instance: instance
app.kubernetes.io/name: app
app.kubernetes.io/instance: instance
app.kubernetes.io/component: component
Is there any way to merge the two includes in app.component.labels definition so that the duplicates will merge?