<p>I have an ngnix kubernetes pod that I need to pass an <code>.env</code> file to but I can't get it to work.</p>
<p>Docker file for the pod:</p>
<pre class="lang-sh prettyprint-override"><code>FROM node:12-alpine as build-step

RUN mkdir /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build

FROM nginx:1.17.1-alpine
COPY --from=build-step /app/build /usr/share/nginx/html
</code></pre>
<p>I've tried with to pass the env with the configmap:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test-front-app
data:
  ENV_TEST: &quot;TEST&quot;
</code></pre>
<p>And with passing the <code>env</code> in the <code>Deployment</code> but neither worked.</p>
<p>edit the deployment file:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: test-front-app
  name: test-front-app
spec:
  replicas: 2
  selector:
    matchLabels:
      name: test-front-app
  template:
    metadata:
      labels:
        name: test-front-app
    spec:
      imagePullSecrets:
        - name: gcr-json-key
      containers:
      - name: front-test
        image: gcr.io/PROJECT_ID/IMAGE:TAG
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
        env:
          - name: TEST_ONE
            value: &quot;test-value-one/&quot;
        envFrom:
          - configMapRef:
              name: test-front-app
</code></pre>

nikoola
<p>Your ConfigMap <code>test-front-app</code> key can be accessed as env like below.</p>
<pre><code>    env:
    - name: TEST_ONE
      valueFrom:
        configMapKeyRef:
          name: test-front-app
          key: ENV_TEST
</code></pre>
<p>In this way <code>TEST_ONE</code> variable with value of <code>TEST</code> will be passed to deployment.</p>
