<p>This is what I currently have:</p>

<p>With the basic <code>helm create</code> comes a <code>values.yaml</code> file and a <code>template</code> folder with a <code>deployment.yaml</code>.
The <code>Deployment</code> file has been adapted to manage a spring-boot application in a docker image.</p>

<p>Now the <code>values.yaml</code> contains something like </p>

<pre><code>myApp:
  repository: myApp.mycompany.com/demo/my-app-customers
  tag: stable
</code></pre>

<p>And the <code>deployment.yaml</code> contains </p>

<pre><code>spec:
  template:
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.myApp.repository }}:{{ .Values.myApp.tag }}"
</code></pre>

<p>Let's say I have to manage another spring-boot app, really close to what "my-app-customers" is.  I thought that I would just have to add another line to <code>values.yaml</code>, like that:</p>

<pre><code>mySecondApp:
  repository: myApp.mycompany.com/demo/my-app-others
  tag: stable
</code></pre>

<p>But this wouldn't work with <code>deployment.yaml</code> because it uses <code>.Values.myApp.repository</code>. Which means that I need  to create another file <code>deployment-others.yaml</code> which uses <code>.Values.mySecondApp.repository</code> to deploy this second app. So it is not possible to use the same template for differents applications.</p>

<ul>
<li>Am I correct or did I miss something ?</li>
<li>Would there be another way to do this or do I need to copy past similar deployment (and others) file and have one template file per application ?</li>
</ul>

<p>The standard way to do this is to have a <code>second-deployment.yaml</code> file which is essentially a copy of the first one, but with different labels and value references.  It's customary to put some templates in <code>_helpers.tpl</code> to generate things like the labels blocks and you can extend these for common environment variables, or you can offload some of the configuration into a ConfigMap to reduce the duplication.</p>

<p>The templating layer of Helm isn't really aware of YAML syntax at all, so just as long as each file produces valid YAML, you can do anything you want.  That can include multiple documents in a single file, and they can be generated by templating.  This can get tricky, though.  The basic outline might look like</p>

<pre><code>{{- range list .Values.myApp .Values.mySecondApp -}}
---
...
spec:
  template:
    spec:
      containers:
        - name: {{ $.Chart.Name }}
          image: "{{ .repository }}:{{ .tag }}"
...
{{ end -}}
</code></pre>

<p>If you try this, you need to be aware that <code>.</code> is a fragment of the values object and not the root object like it usually is; note for example <code>$.Chart.Name</code> to explicitly reference the top-level chart name.</p>
