<p>Structure like this:</p>
<pre><code>chart.yaml
values.yaml
templates/
|__deploymentconfig.yaml
</code></pre>
<p>Usage: <code>helm install demo --dry-run --debug -f values.yaml</code></p>
<p>What i like to do is, to add an <code>environment variable</code> with the <code>--set</code> command on <code>helm install</code> after the template has filled the yaml.</p>
<p>Dummy Command like this (not working):<br />
<code>helm install demo ... -f values.yaml --set ???env[0].name=MyEnvVar</code></p>
<p>Resulting deployment config should look like this:</p>
<pre class="lang-bash prettyprint-override"><code>kind: Deployment
...
spec:
  template:
    spec:
      containers:
        env:
          - name: MyEnvVar
            value: Hello
</code></pre>
<p>What do i need to set on the <strong>???</strong> part of the install command to get the desired variable in the deployment part of the manifest?</p>

flymg
<p>In a comment you clarify:</p>
<blockquote>
<p>I would like to add an environment variable without touching the Helm code (only using <code>--set</code> on CLI)</p>
</blockquote>
<p>You can't use <code>helm install --set</code> to make any changes that aren't described in the template code.  If your chart says, for example,</p>
<pre class="lang-yaml prettyprint-override"><code>env:
  - name: SOME_VARIABLE
    value: {{ .Values.someValue | default &quot;foo&quot; }}
</code></pre>
<p>then you could <code>helm install --set someValue=bar</code> to change the one specific environment value, but your chart itself has no way to supply additional environment variables, and <code>--set</code> on its own can't change this.</p>
<blockquote>
<p>Reason: No Test Code goes to production.</p>
</blockquote>
<p>You can still allow customizing the chart without breaking this rule.  If &quot;is it production&quot; controls a specific set of things, you can make that a deploy-time control</p>
<pre class="lang-yaml prettyprint-override"><code>env:
  - name: ENVIRONMENT
    value: {{ Values.environment | default &quot;production&quot; }}
</code></pre>
<pre class="lang-bash prettyprint-override"><code>helm install --set environment=development ...
</code></pre>
<p>Or you could provide an open-ended set of extension environment variables, expecting that to normally be empty</p>
<pre class="lang-yaml prettyprint-override"><code>env:
{{- with .Values.extraEnvironment }}
{{ toYaml . | indent 2 }}
{{- end }}
</code></pre>
<p>The corresponding <code>helm install --set</code> syntax for this would be trickier, but you could write a separate YAML file of deploy-time values to inject with <code>helm install -f</code>.</p>
<p>In principle you could use <a href="https://docs.helm.sh/docs/topics/advanced/#post-rendering" rel="nofollow noreferrer">post rendering</a> to make arbitrary changes to the deployed YAML, and that could include adding environment variables.  That's a complex approach, though, and it leaves you in the situation of having tested something with modifications from the standard deployment; that might not be reproducible enough for many needs.</p>
