Skip to content

Commit 5ba3729

Browse files
Explain env vs envFrom for page Define Environment Variables for a Container (#40055)
* 'Define Environment Variables for a Container' does not explain env vs envFrom #39873 * suggested review changes done. * tengqm suggested changes done.
1 parent d99127d commit 5ba3729

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

content/en/docs/tasks/inject-data-application/define-environment-variable-container.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ When you create a Pod, you can set environment variables for the containers
2121
that run in the Pod. To set environment variables, include the `env` or
2222
`envFrom` field in the configuration file.
2323

24+
The `env` and `envFrom` fields have different effects.
25+
26+
`env`
27+
: allows you to set environment variables for a container, specifying a value directly for each variable that you name.
28+
29+
`envFrom`
30+
: allows you to set environment variables for a container by referencing either a ConfigMap or a Secret.
31+
When you use `envFrom`, all the key-value pairs in the referenced ConfigMap or Secret
32+
are set as environment variables for the container.
33+
You can also specify a common prefix string.
34+
35+
You can read more about [ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables)
36+
and [Secret](/docs/tasks/inject-data-application/distribute-credentials-secure/#configure-all-key-value-pairs-in-a-secret-as-container-environment-variables).
37+
38+
This page explains how to use `env`.
39+
2440
In this exercise, you create a Pod that runs one container. The configuration
2541
file for the Pod defines an environment variable with name `DEMO_GREETING` and
2642
value `"Hello from the environment"`. Here is the configuration manifest for the

0 commit comments

Comments
 (0)