Bitzu

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

Single choice

Which object is meant for non-confidential configuration data consumed by Pods?

  1. Secret
  2. ConfigMap
  3. Namespace
  4. ReplicaSet
Show answer

Answer: B. ConfigMap

ConfigMap is for plain configuration. Secret is the object for sensitive values.

Select all that apply

Which are ways a Pod can consume a ConfigMap?

  1. As environment variables
  2. As files in a mounted volume
  3. In a container's command and args
  4. By baking it into image layers at runtime
  5. 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.

True or false

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.

Download on the App StoreGet it on Google Play

More KCNA topics in this module