<p>In my helm chart, I have a few files that need credentials to be inputted
For example</p>
<pre><code>&lt;Resource
    name=&quot;jdbc/test&quot;
    auth=&quot;Container&quot;
    driverClassName=&quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot;
    url=&quot;jdbc:sqlserver://{{ .Values.DB.host }}:{{ .Values.DB.port }};selectMethod=direct;DatabaseName={{ .Values.DB.name }};User={{ Values.DB.username }};Password={{ .Values.DB.password }}&quot;
    /&gt;
</code></pre>
<p>I created a secret</p>
<pre><code>Name: databaseinfo
   Data:
     username
     password
</code></pre>
<p>I then create environment variables to retrieve those secrets in my deployment.yaml:</p>
<pre><code>env:
   - name: DBPassword
      valueFrom:
      secretKeyRef:
        key: password
        name: databaseinfo
   - name: DBUser
       valueFrom:
       secretKeyRef:
         key: username
         name: databaseinfo 
</code></pre>
<p>In my values.yaml or this other file, I need to be able to reference to this secret/environment variable. I tried the following but it does not work:
values.yaml</p>
<pre><code>DB:
  username: $env.DBUser
  password: $env.DBPassword
</code></pre>

Oplop98
<p>you can't pass variables from any template to <code>values.yaml</code> with helm. Just from <code>values.yaml</code> to the templates.</p>
<p>The answer you are seeking was posted by <a href="https://stackoverflow.com/users/3061469/mehowthe">mehowthe</a> :</p>
<p>deployment.yaml =</p>
<pre><code>      env:          
        {{- range .Values.env }}
      - name: {{ .name }}
        value: {{ .value }}
     {{- end }}
</code></pre>
<p>values.yaml =</p>
<pre><code>env:          
 - name: &quot;DBUser&quot;
   value: &quot;&quot;
 - name: &quot;DBPassword&quot;
   value: &quot;&quot;
</code></pre>
<p>then</p>
<p><code>helm install chart_name --name release_name --set env.DBUser=&quot;FOO&quot; --set env.DBPassword=&quot;BAR&quot;</code></p>
