What is a ConfigMap and when would you use it over an environment variable?

Easy Topic: Kubernetes May 24, 2026

A ConfigMap stores non-sensitive configuration data as key-value pairs. It decouples your configuration from your container image.

Use ConfigMaps over hardcoded env vars when:

  • Config needs to differ between environments (dev/staging/prod)
  • Multiple pods share the same configuration
  • You need to mount config as a file (e.g., nginx.conf, prometheus.yml)

For sensitive data like passwords, use a Secret instead of a ConfigMap.

← Previous Explain Kubernetes network policies and how you would... Next → How do you troubleshoot high memory usage causing...

Practice Similar Questions

Back to Kubernetes Topics