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 ## Defining an environment variable for a container
When you create a Pod, you can set environment variables for the containers 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 that run in the Pod. To set environment variables, include the `env` or
the configuration file. `envFrom` field in the configuration file.
In this exercise, you create a Pod that runs one container. The configuration 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 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 ### Use-Case: Consume ConfigMap in environment variables
ConfigMaps can be used to populate environment variables. As an example, consider ConfigMaps can be used to populate individual environment variables or used in
the following ConfigMap: its entirety. As an example, consider the following ConfigMaps:
```yaml ```yaml
apiVersion: v1 apiVersion: v1
@@ -258,6 +258,16 @@ data:
special.type: charm 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: We can consume the keys of this ConfigMap in a pod like so:
```yaml ```yaml
@@ -281,6 +291,9 @@ spec:
configMapKeyRef: configMapKeyRef:
name: special-config name: special-config
key: special.type key: special.type
envFrom:
- configMapRef:
name: env-config
restartPolicy: Never restartPolicy: Never
``` ```
@@ -289,6 +302,7 @@ When this pod is run, its output will include the lines:
```shell ```shell
SPECIAL_LEVEL_KEY=very SPECIAL_LEVEL_KEY=very
SPECIAL_TYPE_KEY=charm SPECIAL_TYPE_KEY=charm
log_level=INFO
``` ```
#### Optional ConfigMap in environment variables #### Optional ConfigMap in environment variables