<p>I've configured two container into a pod.</p>

<p>The first of them is engaged to create a file like:</p>

<pre><code>SPRING_DATASOURCE_USERNAME: username
SPRING_DATASOURCE_PASSWORD: password
</code></pre>

<p>I want that the second container reads from this location in order to initialize its env variables.</p>

<p>I'm using <code>envFrom</code> but I don't quite figure out how to use it.</p>

<p>This is my spec:</p>

<pre><code>metadata:
  annotations:
    configmap.fabric8.io/update-on-change: ${project.artifactId}
  labels:
    name: wsec
  name: wsec
spec:
  replicas: 1
  selector:
    name: wsec
    version: ${project.version}
    provider: fabric8
  template:
    metadata:
      labels:
        name: wsec
        version: ${project.version}
        provider: fabric8
    spec:
      containers:
      - name: sidekick
        image: quay.io/ukhomeofficedigital/vault-sidekick:latest
        args:
        - -cn=secret:openshift/postgresql:env=USERNAME
        env:
        - name: VAULT_ADDR
          value: "https://vault.vault-sidekick.svc:8200"
        - name: VAULT_TOKEN
          value: "34f8e679-3fbd-77b4-5de9-68b99217cc02"
        volumeMounts:      
        - name: sidekick-backend-volume
          mountPath: /etc/secrets
          readOnly: false

      - name: wsec
        image: ${docker.image}
        env:
        - name: SPRING_APPLICATION_JSON
          valueFrom:
           configMapKeyRef:
             name: wsec-configmap
             key: SPRING_APPLICATION_JSON
          envFrom:
            ???
      volumes:
      - name: sidekick-backend-volume
        emptyDir: {}
</code></pre>

Jordi
<p>It looks like you are packaging the environment variables with the first container and read then in the second container. 
If that's the case, you can use <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">initContainers</a>. </p>

<p>Create a volume mapped to an emptyDir. Mount that on the initContainer(propertiesContainer) and the main container(springBootAppContainer) as a volumeMount. This directory is now visible to both containers. </p>

<pre><code>    image: properties/container/path
    command: [bash, -c]
    args: ["cp -r /location/in/properties/container /propsdir"]
    volumeMounts:
    - name: propsDir
      mountPath: /propsdir
</code></pre>

<p>This will put the properties in /propsdir. When the main container starts, it can read properties from /propsdir</p>
