I am having trouble accessing some named templates defined in the main chart from subcharts. As it is in the documentation that every defined named template is global, I'd like to get help on what I am doing wrong here.
Below is the defined named template in _helper.tpl of the main chart and I am trying to access it in the configMap from the subchart which is resulting into an error of no template.
_helper.tpl inside chart/templates
{{- define "main.postgres"}}
POSTGRES_URL: 172.30.30.39
POSTGRES_PORT: 5432
{{- end }}
configMap.yaml inside chart/subchart/templates
apiVerions: v1
kind: ConfigMap
metadata:
name: subchart-config
data:
{{- template "main.postgres" .}}
Error
error calling include: template: no template "main.postgres" associated with template "gotpl"
.tpl
to the end of your template tpl? So it's "main.postgres.tpl?" Also looking back at some I made I found that I added code at the bottom of all my files. So I define the tpl at the top level and the bottom have the following. {{- define "main.postgres" -}} {{- include "main.postgres.util.merge" (append . "main.postgres.tpl") -}} {{- end -}}