<p>I'm relatively new to K8S and hit a road block. I've created a ConfigMap to create a central location so that all Deployments can pull in and mount the same vars - something like so:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
    name: site
    namespace: staging
spec:
    revisionHistoryLimit: 1
    replicas: 1
    template:
        metadata:
            labels:
                app: site
    spec:
        containers:
            - name: nginx
              image: gcr.io/XXX/builds/nginx:develop-latest
              imagePullPolicy: Always
              command: ["nginx", "-g", "daemon off;"]
              ports:
                - containerPort: 80
              livenessProbe:
                httpGet:
                  path: /
                  port: 80
                initialDelaySeconds: 10
              readinessProbe:
                httpGet:
                  path: /
                  port: 80
                initialDelaySeconds: 10

            - name: php
              image: gcr.io/XXX/builds/php:develop-latest
              imagePullPolicy: Always
              command: ["php-fpm7.0", "--nodaemonize", "-R"]
              livenessProbe:
                tcpSocket:
                  port: 9000
                initialDelaySeconds: 10
              readinessProbe:
                tcpSocket:
                  port: 9000
                initialDelaySeconds: 10
              env:
                - name: ENV_PATH
                  value: /etc/config/.env
              volumeMounts:
                - name: config-volume
                  mountPath: /etc/config
        volumes:
            - name: config-volume
              configMap:
                name: staging-config
                items:
                  - key: site
                    path: .env
</code></pre>

<p>It mounts the file correctly -- I can see it when I <code>ls</code> inside the pod, but I'm struggling to expose the contents of the file to act as environment variables that my Laravel app can use. When defining them normally everything works as expected (see below), but taking the above approach they simply do not get set. The docs doesn't lend any further help and I'm not seeing anything online... Any pointers?</p>

<pre><code>env:
  - name: variable
    value: val
  - name: var2
    value: var2val
</code></pre>

<p>If you want to set values from your configMap directly as env vars inside your pod, then you do not need to mount them as files. Instead use:</p>

<pre><code>env:
  - name: MY_ENV_VAR
    valueFrom:
      configMapKeyRef:
        name: &lt;your-configmap-name&gt;
        key: &lt;key-of-your-value&gt;
</code></pre>

<p>If you want to stick with the mounting option, another way might be to use your <code>docker-entrypoint.sh</code> script of your laravel container to somehow source the mounted env file when you start the container.</p>
