Initial docs for envFrom ConfigMap

This commit is contained in:
Michael Fraenkel
2016-12-15 12:46:03 -05:00
committed by Andrew Chen
parent ae4bc86dae
commit 15e529958e
2 changed files with 18 additions and 4 deletions
@@ -22,8 +22,8 @@ in a Kubernetes Pod.
## Defining an environment variable for a container
When you create a Pod, you can set environment variables for the containers
that run in the Pod. To set environment variables, include the `env` field in
the configuration file.
that run in the Pod. To set environment variables, include the `env` or
`envFrom` field in the configuration file.
In this exercise, you create a Pod that runs one container. The configuration
file for the Pod defines an environment variable with name `DEMO_GREETING` and
+16 -2
View File
@@ -244,8 +244,8 @@ metadata:
### Use-Case: Consume ConfigMap in environment variables
ConfigMaps can be used to populate environment variables. As an example, consider
the following ConfigMap:
ConfigMaps can be used to populate individual environment variables or used in
its entirety. As an example, consider the following ConfigMaps:
```yaml
apiVersion: v1
@@ -258,6 +258,16 @@ data:
special.type: charm
```
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: env-config
namespace: default
data:
log_level: INFO
```
We can consume the keys of this ConfigMap in a pod like so:
```yaml
@@ -281,6 +291,9 @@ spec:
configMapKeyRef:
name: special-config
key: special.type
envFrom:
- configMapRef:
name: env-config
restartPolicy: Never
```
@@ -289,6 +302,7 @@ When this pod is run, its output will include the lines:
```shell
SPECIAL_LEVEL_KEY=very
SPECIAL_TYPE_KEY=charm
log_level=INFO
```
#### Optional ConfigMap in environment variables