Injecting ConfigMap and Secret Data Into Pods and Containers

Learn how to inject ConfigMap and secret data into Pods and containers.

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.

Get hands-on with 1400+ tech skills courses.