title: How can you call a helm 'helper' template from a subchart with the correct context?
body: <p><a href="https://github.com/kubernetes/helm" rel="noreferrer">Helm</a> charts define helper templates in <code>_helpers.tpl</code> which are used to create normalized names for the services. The standard form of the template for a service (DNS) name is:</p>
  <pre><code>{{- define &quot;postgresql.fullname&quot; -}}
  {{- $name := default .Chart.Name .Values.nameOverride -}}
  {{- printf &quot;%s-%s&quot; .Release.Name $name | trunc 63 | trimSuffix &quot;-&quot; -}}
  {{- end -}}
  </code></pre>
  <p>If using <em>postgresql</em> as a subchart, how are you supposed to use DNS-based service discovery to refer to it? A common pattern seems to be to copy the subchart helpers into the parent chart.</p>
  <pre><code>{{- define &quot;keycloak.postgresql.fullname&quot; -}}
  {{- $name := default &quot;postgresql&quot; .Values.postgresql.nameOverride -}}
  {{- printf &quot;%s-%s&quot; .Release.Name $name | trunc 63 | trimSuffix &quot;-&quot; -}}
  {{- end -}}
  </code></pre>
  <p>This is total madness for obvious reasons!!!</p>
  <p>Surely there's a better way to use the subchart helper? If you could create a context object then it would be possible to invoke it, something like:</p>
  <pre><code>value: {{ template &quot;postgresql.fullname&quot; ({Chart: {Name: 'not-used'}, Release: {Name: .Release.Name}, Values: { nameOverride: .Values.postgresql.nameOverride}}) }}
  </code></pre>
  <p>Sadly I have no idea how to actually create such a context dynamically. This would still break if the helper function changed to reference new properties, but in an obvious way.</p>
  <p>Alternatively, a different way to make available the service name from a subchart?</p>