CKAD lab · Expose application settings through a ConfigMap
A worker needs LOG_LEVEL=info without baking it into its image.

Initial conditions
Use a disposable namespace lab. Save the Pod manifest as pod.yaml.
Objective
Create the ConfigMap and reference a single key as an environment variable.
Hint
Use valueFrom.configMapKeyRef in the container environment.
Solution manifest
apiVersion: v1
kind: Pod
metadata:
name: config-demo
spec:
containers:
- name: worker
image: busybox:1.36
command: ["sleep", "3600"]
env:
- name: LOG_LEVEL
valueFrom:
configMapKeyRef:
name: app-settings
key: logLevelSolution commands
kubectl -n lab create configmap app-settings --from-literal=logLevel=info
kubectl -n lab apply -f pod.yamlValidate the result
kubectl -n lab wait --for=condition=Ready pod/config-demo --timeout=60s
kubectl -n lab exec config-demo -- printenv LOG_LEVELThe container prints info. Environment variables are set when the container starts, so changing the ConfigMap requires a restart to refresh this value.
Common mistakes
Mixing the variable name and ConfigMap key causes a configuration error. Use a Secret for sensitive values.
Free official documentation · Verified 26 November 2026
Use your own disposable Kubernetes environment.
