ConfigMaps: Environment Variables and Volume Mounts
There are three ways to create a ConfigMap and four ways to consume one, and CKAD tasks use all of them. This puts every consumption style into a single Pod so they can be compared in one log, then shows the failure a missing key produces - a status that is neither Running nor CrashLoopBackOff and that names the exact key it could not find.
Configuration and Security Guide 24 of 44 Beginner
- Kubernetes1.36.4
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 16 min
- Reviewed23 August 2026
Written against the versions above. `--from-env-file` reads `KEY=value` lines and makes one ConfigMap key per line; `--from-file` makes ONE key whose name is the filename and whose value is the whole file. Mixing those two up is the usual reason a mounted config file arrives as a directory of fragments or a single unusable blob.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
Before you start
- A cluster and kubectl.
- The session creates namespace
ckad-cmwith three ConfigMaps built three different ways, and four Pods that consume them.
-
Three ways to create one
-
Four ways to consume one
-
The key that is not there
-
optional makes it tolerable