<p>Can someone explain to me what the role of the keyword &quot;template&quot; is in this code :</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: {{ template &quot;identity-openidconnect&quot; . }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ template &quot;microService.name&quot; . }}
    release: &quot;{{ .Release.Name }}&quot;
    xxxx
xxxxxxxxxxxx
</code></pre>

<p>The keyword &quot;template&quot; means, that Helm will find the previously created template and complete the yaml file according to the template in the template. It has to be created in advance. This type of construction allows you to refer to the same scheme many times.</p>
<p>For example, we can define a template to encapsulate a Kubernetes block of labels:</p>
<pre class="lang-yaml prettyprint-override"><code>{{- define &quot;mychart.labels&quot; }}
  labels:
    generator: helm
    date: {{ now | htmlDate }}
{{- end }}
</code></pre>
<p>Now we can embed this template inside of our existing ConfigMap, and then include it with the  <code>template</code>  action:</p>
<pre class="lang-yaml prettyprint-override"><code>{{- define &quot;mychart.labels&quot; }}
  labels:
    generator: helm
    date: {{ now | htmlDate }}
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
  {{- template &quot;mychart.labels&quot; }}
data:
  myvalue: &quot;Hello World&quot;
  {{- range $key, $val := .Values.favorite }}
  {{ $key }}: {{ $val | quote }}
  {{- end }}
</code></pre>
<p>When the template engine reads this file, it will store away the reference to  <code>mychart.labels</code>  until  <code>template &quot;mychart.labels&quot;</code>  is called. Then it will render that template inline. So the result will look like this:</p>
<pre class="lang-yaml prettyprint-override"><code># Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: running-panda-configmap
  labels:
    generator: helm
    date: 2016-11-02
data:
  myvalue: &quot;Hello World&quot;
  drink: &quot;coffee&quot;
  food: &quot;pizza&quot;
</code></pre>
<p>Note: a  <code>define</code>  does not produce output unless it is called with a template, as in this example.</p>
<p>For more info about <code>templates</code> you can read <a href="https://helm.sh/docs/chart_template_guide/named_templates/" rel="noreferrer">this page</a>.</p>
