Learn Kubernetes: ConfigMap — Inject the values of a ConfigMap in a container as a volume

Bruno Delb
DevOps & AI Academy
3 min readFeb 21, 2022

--

In this series of stories, you will learn how to use Kubernetes. Today, let’s inject the values of a ConfigMap in a container as a volume.

After this story, you can read the following stories:

In first, let’s store the Nginx configuration file nginx.conf in a ConfigMap:

kubectl create configmap nginx-config --from-file=./nginx.conf

If the command succeeds, the output is:

configmap/nginx-config created

Confirm that the contents of the nginx.conf file are in the data: section of the ConfigMap:

kubectl get cm nginx-config -o yaml

The output is similar to:

apiVersion: v1
data:
nginx.conf: |
server {
listen 80;
root /usr/share/nginx/html;
}
kind: ConfigMap
metadata:
creationTimestamp: "2022-02-21T09:46:18Z"
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:data:
.: {}…

--

--

Bruno Delb
DevOps & AI Academy

Blockchains, DevOps, Agile Coaching, development, testing, Cloud, Management 3.0, ITIL. It defines me.