Search⌘ K

Injecting Configurations from Multiple Files

Explore how to create and manage Kubernetes ConfigMaps using multiple files and directories. Learn to inject these configurations into Pods, enabling flexible and centralized management of application settings in a cluster environment.

Creating a ConfigMap from multiple files

Let's see what happens when we execute the following commands:

Shell
kubectl create cm my-config \
--from-file=cm/prometheus-conf.yml \
--from-file=cm/prometheus.yml
kubectl create -f cm/alpine.yml
#Run the following command separately
kubectl exec -it alpine -- \
ls /etc/config

We create a ConfigMap with two files and the same Pod based on the alpine.yml definition. Finally, we output the list of files from the /etc/config directory inside the Pod’s only container. The output of the latter command is as follows:

Shell
prometheus-conf.yml prometheus.yml

We can ...