<p>I have the values file with some attributes that will be used on mount volumes. As example:</p>
<pre class="lang-yaml prettyprint-override"><code>secrets:
  my-secret:
    as: volume
    key: file.xml
    mountPath: /etc/xml
</code></pre>
<p>I'm trying to mount volumes only if the value of <code>as</code> is <code>volume</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>          volumeMounts:
          {{- range $name, $value := .Values.secrets }}
            {{- if eq $value.as &quot;volume&quot; }}
            - name: {{ $name }}-volume
              mountPath: {{ quote $value.mountPath }}
            {{- end }}
          {{- end }}
</code></pre>
<p>For some reason, it's failing:</p>
<pre class="lang-sh prettyprint-override"><code>Error: Deployment.apps &quot;webanalytics&quot; is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: &quot;my-secret-volume&quot;
</code></pre>
<p>Any idea on what's wrong?</p>

<p>The logs show that you are accessing <code>&quot;my-secret-volume&quot;</code>.  But that has to exist in your Kubernetes cluster in the same namespace. The error shows that it doesn't exist so you have to <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">create it</a> ⚒️.</p>
<p>Because you didn't share the whole template it could be that the secrets is actually created by the Helm template but it has a different name from <code>&quot;my-secret-volume&quot;</code></p>
<p>☮️✌️</p>
