<p>Is it possible to import environment variables from a different .yml file into the deployment file. My container requires environment variables.</p>

<p><em>deployment.yml</em></p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: api-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - name: api
        image: &lt;removed&gt;
        imagePullPolicy: Always
        env:
        - name: NODE_ENV
          value: "TEST"
        ports:
        - containerPort: 8080
      imagePullSecrets:
      - name: regcred
</code></pre>

<p><em>vars.yml</em></p>

<pre><code>NODE_ENV: TEST
</code></pre>

<p>What i'd like is to declare my variables in a seperate file and simply import them into the deployment.</p>

Kay
<p>What you describe sounds like a <a href="https://helm.sh/" rel="nofollow noreferrer">helm</a> use case. If your deployment were part of a helm chart/template then you could have different values files (which are yaml) and inject the values from them into the template based on your parameters at install time. Helm is a common choice for helping to <a href="https://stackoverflow.com/a/43378990/9705485">manage env-specific config</a>.</p>

<p>But note that if you just want to inject an environment variable in your yaml rather than taking it from another yaml then a popular way to do <a href="https://serverfault.com/questions/791715/using-environment-variables-in-kubernetes-deployment-spec">that is <code>envsubst</code></a>. </p>
