Azure Kubernetes Container Env Variables

9/17/2019

so in Docker, I can do a Docker run -e to pass in environment variables.

But how does one do that for Azure Kubernetes Pods? They aren't username/password kinds of variables but more so URLs segments we would want to use during startup.

http://webapi/august where august is what we would want to pass in, then in September, we would want to pass in september.

This aren't the best examples, but it shows what I'm looking for.

Thanks.

-- Nick Jacobs
azure
azure-kubernetes
docker

1 Answer

9/18/2019

There is a clear example on kubernetes documentation for this - https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/

Short example from there:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
        env:
        - name: DEMO_GREETING
          value: "Hello from the environment"
        - name: DEMO_FAREWELL
          value: "Such a sweet sorrow"

Take a note of env

later if you want to change the variable on the fly - you can use kubectl set env -h command

-- JleruOHeP
Source: StackOverflow