<p>I have created a secret.yaml file as follows:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: my-secret
data:
  truststore.jks: {{ (.Files.Glob &quot;../trust.jks&quot;).AsSecrets | b64enc }}
</code></pre>
<p>I am calling this as part of template .yaml file in HELM.</p>
<p>.yaml</p>
<pre><code>apiVersion: v1
kind: DeploymentConfig
spec:
...
template:
  spec:
  ...
  container:
   - name: &quot;my-container&quot;
     ...
     volumeMounts:
        - name: secrets
          mountPath: /mnt/secrets
          readOnly: true

 volumes:
    - name: secrets
      secret:
        secretName: &quot;my-secret&quot;
</code></pre>
<p>When I run helm install command the pod gets created successfully, and the volume is also mounted, but if I check the <code>truststore.jks</code> in /mnt/secrets using cat command below is the output:</p>
<pre><code>cat /mnt/secrets/truststore.jks
{}
</code></pre>
<p>I ran the dry run command to check the generated .yaml file, the secret is populted as below:</p>
<pre><code># Source: ag-saas/templates/tsSecret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: my-secret
data:
  truststore.jks: e30=
</code></pre>
<p>How do I get the file into my secret?</p>

Q2Dev
<p>There's a couple of things going on here:</p>
<ul>
<li><code>.Files.Glob</code> is intended to retrieve multiple files, <em>e.g.</em> <code>.Files.Glob &quot;credentials/*.jks&quot;</code>.  For a single file <code>.File.Get</code> will retrieve its contents directly.</li>
<li>You can only access files inside the chart directory; referencing <code>.Files.Get &quot;../trust.jks&quot;</code> won't work.</li>
<li><code>.Files.Glob.AsSecret</code> renders a list of files to the entire contents of the <code>data:</code> block; you just directly need the file content.</li>
</ul>
<p>So your Secret should look like</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Secret
metadata:
  name: my-secret
data:
  truststore.jks: {{ .Files.Get &quot;trust.jks&quot; | b64enc }}
</code></pre>
<p>where in the last line I've used <code>.Files.Get</code>, I've not tried to refer to a <code>&quot;../...&quot;</code> path outside the chart, and I don't render it to <code>...AsSecret</code>.</p>
<p>You also will need to move or copy (not symlink) the keyset file into the chart directory for this to work.</p>
<p>(In the current form, <code>.Files.Glob</code> won't match anything outside the chart directory, so you get an empty list of files.  Then rendering that to <code>.AsSecrets</code> gets you an empty JSON object.  You're using that string <code>{}</code> as the secret value, which gets correctly base64-encoded, but that's why <code>{}</code> comes out at the end.)</p>
