<p>I want to use application.yaml file to be passed as a config map.</p>

<p>So I have written this.</p>

<pre><code> apiVersion: v1
 kind: ConfigMap
 metadata:
  name: conf
data:
{{ (.Files.Glob "foo/*").AsConfig | indent 2 }}
</code></pre>

<p>my application.yaml is present in foo folder and 
contains a service name which I need it to be dynamically populated via helm interpolation.</p>

<pre><code>foo:
  service:
    name: {{.Release.Name}}-service
</code></pre>

<p>When I dry run , I am getting this</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: conf
data:
  application.yaml: "ei:\r\n  service:\r\n    name: {{.Release.Name}}-service"
</code></pre>

<p>but I want <code>name: {{.Release.Name}}-service</code> to contain actual helm release name.</p>

<p>Is it possible to do templating for external files using helm , if yes then how to do it ?
I have gone through <a href="https://v2-14-0.helm.sh/docs/chart_template_guide/#accessing-files-inside-templates" rel="noreferrer">https://v2-14-0.helm.sh/docs/chart_template_guide/#accessing-files-inside-templates</a>
I didn't find something which solves my use case.
 I can also copy the content to config map yaml and can do interpolation but I don't want to do it. I want application.yml to be in a separate file, so that, it will be simple to deal with config changes..</p>

aravind
<p>Helm <a href="https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function" rel="noreferrer">includes a <code>tpl</code> function</a> that can be used to expand an arbitrary string as a Go template.  In your case the output of <code>...AsConfig</code> is a string that you can feed into the template engine.</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-conf
data:
{{ tpl (.Files.Glob "foo/*").AsConfig . | indent 2 }}
</code></pre>

<p>Once you do that you can invoke arbitrary template code from within the config file.  For example, it's common enough to have a defined template that produces the name prefix of the current chart as configured, and so your config file could instead specify</p>

<pre><code>foo:
  service:
    name: {{ template "mychart.name" . }}-service
</code></pre>
