<p>I have <strong>values.yml</strong> file that takes in a list of mountPaths with this format:</p>
<pre><code>global:
  mountPath:
    hello:
      config: /etc/hello/hello.conf
      node: /opt/hello/node.jks
      key: /opt/hello/key.jks
      cert: /opt/hello/cert.jks
</code></pre>
<p>I want the resulting rendered template to be</p>
<pre><code>      volumeMounts:
        - name: config
          mountPath: /etc/hello/hello.conf
          subPath: config
        - name: node
          mountPath: /opt/hello/node.jks
          subPath: node
        - name: key
          mountPath: /opt/hello/key.jks
          subPath: key
        - name: cert
          mountPath: /opt/hello/cert.jks
          subPath: cert
</code></pre>
<p>How would I accomplish this? I tried the following in my <strong>deployment.yaml</strong> template file:</p>
<pre><code>      volumeMounts:
      {{- range $key, $value := pluck .Values.service_name .Values.global.mountPath.serviceName | first }}
        - name: {{ $key }}
          mountPath: $value
          subPath: {{ $key }}
      {{- end }}
</code></pre>
<p>the following helm command that i have run but the it won't work for me. How do I accomplish getting to the format I want above based on the input?</p>
<pre><code>helm upgrade --install \
  --namespace ${NAMESPACE} \
  --set service_name=hello \
  --set namespace=${NAMESPACE} \
  hello . \
  -f values.yaml \
</code></pre>

エック
<p>Here is what I did:</p>
<pre><code>      volumeMounts:
      {{- range $key, $value := pluck .Values.service_name .Values.global.mountPath | first }}
        - name: {{ $key }}
          mountPath: {{  $value }}
          subPath: {{ $key }}
      {{- end }}
</code></pre>
<p><code>helm template --set service_name=hello [...] </code> seems to render exactly what you want.</p>
<p>Notice I changed the line with mountPath field:  <code>$value</code> -&gt; <code>{{ $value }}</code>,
and the line with range: <code>.Values.global.mountPath.serviceName</code> -&gt; <code>.Values.global.mountPath</code></p>
