KCNA ยท Kubernetes core concepts
ConfigMaps and configuration injection
ConfigMaps and Secrets as env vars or volumes, separating config from images.
Key points
- Keep configuration out of the image so the same image runs in every environment.
- A ConfigMap holds non-confidential key/value data (up to 1 MiB) and a Secret holds sensitive data.
- Pods consume them as environment variables, command arguments or files in a mounted volume; the ConfigMap must be in the Pod's namespace.
Source: https://kubernetes.io/docs/concepts/configuration/configmap/
Practice questions
Which object is meant for non-confidential configuration data consumed by Pods?
- Secret
- ConfigMap
- Namespace
- ReplicaSet
Show answer
Answer: B. ConfigMap
ConfigMap is for plain configuration. Secret is the object for sensitive values.
Which are ways a Pod can consume a ConfigMap?
- As environment variables
- As files in a mounted volume
- In a container's command and args
- By baking it into image layers at runtime
- By editing it directly in etcd from the container
Show answer
Answer: A. As environment variables, B. As files in a mounted volume, C. In a container's command and args
Env vars, volumes and command arguments are supported. Image layers are fixed at build time and containers do not touch etcd.
A ConfigMap is encrypted, so it is a safe place for passwords.
Show answer
Answer: False
ConfigMaps are for non-confidential data and give no secrecy. Passwords belong in a Secret or an external secret tool.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
