<p>I am trying to add a init container to a deployment, but I can´t make the env vars work for some reason.</p>
<p>Just to illustrate, this is what I am trying:</p>
<pre><code>initContainers:
    - name: init-db
      image: mysql:5.7
      env:
        - name: TEST
          value: nada
      args: [&quot;echo&quot;, &quot;${TEST}&quot;]
</code></pre>
<p>But no matter what I do, the env vars doesn´t work, the <code>echo</code> always returns <code>${TEST}</code> instead of <code>nada</code></p>
<p>Any hint?</p>

Stargazer
<p>Like the comments and other answer mentioned you need to use shell for ENV substitution properly. therefore, replace the line</p>
<p><code>      args: [&quot;echo&quot;, &quot;${TEST}&quot;]</code> in you code to</p>
<p><code>      command: ['sh', '-c', 'echo ${TEST}']</code></p>
<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#run-a-command-in-a-shell" rel="nofollow noreferrer">Reference</a></p>
