<p>So, I have a yaml file that looks like this: </p>

<pre><code>service:
        users:
            - username: some-user
              password: some-pass (would be placed in Secret)
            - username: some-user
              password: some-pass (would be placed in Secret)
</code></pre>

<p>I need to add it in env (In spring boot's priority list, config from env is higher than config from yaml. And this would be env(dev,stage,live) based). 
I already tried this with Kustomize</p>

<pre><code>configMapGenerator:
    - name: my-java-server-props
      files:
      - config.yaml
</code></pre>

<p>And then using this in Deployment </p>

<pre><code>envFrom:
  - configMapRef:
      name: my-java-server-props
</code></pre>

<p>Other configs in config.yml like this: </p>

<pre><code>spring:
  datasource:
    url: some-url-here
</code></pre>

<p>are then add in .properties file for configMapGenerator like this:</p>

<pre><code>spring_datasource_url=some-url-here
</code></pre>

<p>but the config with array doesn't seem to work. </p>

<p>any hints on where am I missing the trick? 
Also, the password comes from credstash; so, I have a different script which gets the value from credstash and creates a manifest for Secret. </p>

<p>The end goal to add passwords would be something like this in Deployment: </p>

<pre><code>name: service_users.0.password
      valueFrom:
        secretKeyRef:
          key: value
          name: service-user-store-password
</code></pre>

<p>This was an issue in spring boot from some time ago, support for binding environment variables to array elements. There is a good document to describe the solution on the spring boot wiki: <a href="https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0" rel="noreferrer">https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0</a>.</p>

<p>To summarize, array elements can be indexed using <em>i</em>, so in your case:</p>

<pre><code>env:
- name: SERVICE_USERS_0_PASSWORD
  valueFrom:
    secretKeyRef:
      key: value
      name: service-user-store-password
- name: SERVICE_USERS_1_PASSWORD
  valueFrom:
    secretKeyRef:
      key: value
      name: service-another-user-store-password
</code></pre>
