pkaramol
pkaramol

Reputation: 19402

kubernetes: precedence of environmental variables

Assuming a pod has an environmental variable set both in its spec, as e.g. below

spec:
  containers:
  - name: env-print-demo
    image: bash
    env:
    - name: FOO
      value: "BAR"

as also injected to it via a ConfigMap (but with a different value) which is the one that will be taken into account?

Upvotes: 1

Views: 4947

Answers (2)

hariK
hariK

Reputation: 3069

When a key exists in multiple sources, the value associated with the last source will take precedence.

Override env values defined in container spec

Upvotes: 3

Semah Mhamdi
Semah Mhamdi

Reputation: 166

the value that will be taken is the config map because config map will override the env value that have the same key

Upvotes: -2

Related Questions