<p>I've a ASP.NET core console application that I run in a container on Kubernetes. In the deployment.yaml I've set the environment variable:</p>

<pre><code>env:
   - name: "ASPNETCORE_ENVIRONMENT"
     value: "Development"
</code></pre>

<p>And in the console application I've the following code:</p>

<pre><code>static void Main(string[] args)
 {
            Console.WriteLine("Env: " + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"));
 }
</code></pre>

<p>But the ASPNETCORE_ENVIRONMENT is empty, how can I get to the configured environment variable? I use the same steps in a core webapi project and there I get the variable as follow:</p>

<pre><code>public Startup(IHostingEnvironment env)
{
     env.EnvironmentName
}
</code></pre>

<p>This works in the core webapi but I don't have IHostingEnvironment in the console app.</p>

<p>We use this template to run a ASP.NET Core App in our Kubernetes cluster:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace: &lt;namespace&gt;
  name: &lt;application name&gt;
spec:
  replicas: 1
  minReadySeconds: 15
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: &lt;app-label&gt;
    spec:
      containers:
        - name: &lt;container-name&gt;
          image: &lt;image-name&gt;
          ports:
            - containerPort: 80
          env:
            - name: ASPNETCORE_ENVIRONMENT
              value: "Release"
</code></pre>
