<p>I want to use the direct translation from k8s secret-keys to SpringBoot properties.
Therefore I have a helm chart (but similar with plain k8s):</p>
<pre><code>apiVersion: v1
data:
  app.entry[0].name: {{.Values.firstEntry.name | b64enc }}
kind: Secret
metadata:
  name: my-secret
type: Opaque
</code></pre>
<p>With that my intention is that this behaves as if I'd set the spring property file:</p>
<pre><code>app.entry[0].name: &quot;someName&quot;
</code></pre>
<p>But when I do this I get an error:</p>
<pre><code> Invalid value: &quot;[app.entry[0].name]&quot;: a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name',  or 'KEY_NAME',  or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+'),
</code></pre>
<p>So, <code>[0]</code> seems not to be allowed as a key name for the secrets.</p>
<p><strong>Any idea how I can inject an array entry into spring directly from a k8s secret name?</strong></p>
<p>Shooting around wildly I tried these that all failed:</p>
<ul>
<li><code>  app.entry[0].name: ...</code> -- k8s rejects '['</li>
<li><code>  app.entry__0.name: ...</code> -- k8s ok, but Spring does not recognize this as array (I think)</li>
<li><code>  &quot;app.entry[0].name&quot;: ...</code>  -- k8s rejects '['</li>
<li><code>  'app.entry[0].name': ...</code> -- k8s rejects '['</li>
</ul>

<p>You should be able to use environnment variables like described in <a href="https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0#lists-1" rel="nofollow noreferrer">sprint-boot-env</a>.</p>
<p><code>app.entry[0].name</code> property will be set using <code>APP_ENTRY_0_NAME</code> environment variable. This could be set in your deployment.</p>
<p>Using secret like:</p>
<pre><code>apiVersion: v1
data:
  value: {{.Values.firstEntry.name | b64enc }}
kind: Secret
metadata:
  name: my-secret
type: Opaque
</code></pre>
<p>and then use it with</p>
<pre><code>       env:
       - name: APP_ENTRY_0_NAME
         valueFrom:
           secretKeyRef:
             name: my-secret
             key: value
</code></pre>
