<p>I have a Flask web application running as a Docker image that is deployed to a Kubernetes pod running on GKE. There are a few environment variables necessary for the application which are included in the docker-compose.yaml like so:</p>
<pre class="lang-yaml prettyprint-override"><code>...
services:
  my-app:
    build: 
      ...
    environment:
      VAR_1: foo
      VAR_2: bar
...
</code></pre>
<p>I want to keep these environment variables in the <code>docker-compose.yaml</code> so I can run the application locally if necessary. However, when I go to deploy this using a Kubernetes deployment, these variables are missing from the pod and it throws an error. The only way I have found to resolve this is to add the following to my <code>deployment.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>containers:
      - name: my-app
        ...
        env:
          - name: VAR_1
            value: foo
          - name: VAR_2
            value: bar
...
</code></pre>
<p>Is there a way to migrate the values of these environment variables directly from the Docker container image into the Kubernetes pod?</p>
<p>I have tried researching this in Kubernetes and Docker documentation and Google searching and the only solutions I can find say to just include the environment variables in the <code>deployment.yaml</code>, but I'd like to retain them in the <code>docker-compose.yaml</code> for the purposes of running the container locally. I couldn't find anything that explained how Docker container environment variables and Kubernetes environment variables interacted.</p>

David Gurge
<p>Kompose can translate docker compose files to kubernetes resources:</p>
<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/</a></p>
