Injecting ConfigMap and Secret Data Into Pods and Containers
Learn how to inject ConfigMap and secret data into Pods and containers.
We'll cover the following...
There are three ways to inject ConfigMap data into containers:
As environment variables
As arguments to container startup commands
As files in a volume
Let’s look at each.
ConfigMaps and environment variables
We can inject ConfigMap data into containers as environment variables. However, if we make changes to the ConfigMap after deploying the container, they won’t appear in the container.
The following figure shows the process. We create the ConfigMap and then map its entries into environment variables in the containers
section of the Pod template. Finally, when the container starts, the environment variables appear as standard Linux or Windows environment variables, and apps consume them without even knowing a ConfigMap is involved.
We already have a ConfigMap called multimap with the following two entries:
given=Nigel
family=Poulton
The following Pod manifest deploys a single container with two environment variables that map the CM as follows:
FIRSTNAME: Maps to the given entry in the CM ...