Skip to main content
ConfigMaps in OpenShift 4 behave exactly like ConfigMaps in Kubernetes. Use the same API and commands (oc or kubectl) to create, update, and consume them—no OpenShift-specific changes are required for standard ConfigMap workflows.
ConfigMaps are a Kubernetes namespaced resource for storing non-confidential configuration data as key-value pairs. They let you inject configuration into containers at runtime without baking that configuration into your container images or Deployment manifests. This improves reuse and separation of configuration from code or images. A few common patterns for ConfigMap usage:
  • Provide environment variables to Pods (env or envFrom).
  • Mount configuration files into containers as a volume.
  • Store small runtime configuration snippets consumed by applications.
A presentation slide titled "ConfigMap" with a graphic of red stacked blocks labeled "Environment Variables," "Configuration Data," and "Parameters" next to a gear/circuit icon. The left side shows vertical red buttons with chevrons and the caption "Add Environment Variables and Config Data."
What a ConfigMap stores
  • Stored under the data field as string key-value pairs.
  • Not intended for sensitive values—use Kubernetes Secrets for passwords, tokens, and other sensitive items.
By default, ConfigMaps are stored in etcd in plaintext unless encryption-at-rest is enabled. Any user with RBAC read permissions in the namespace can view them. Never store secrets in ConfigMaps; use Kubernetes Secrets and protect them with appropriate RBAC and encryption-at-rest.

Ways to create and inspect ConfigMaps

Below are the recommended workflows and quick-create options.
  1. Declarative YAML manifest (recommended for source control)
Example ConfigMap manifest:
Apply it:
  1. Imperative (quick/one-off) commands
Create from literals:
Create from a file (file contents become the value for the key named after the file):
  1. Inspecting ConfigMaps
List ConfigMaps in the current namespace:
Describe a specific ConfigMap:
Show the full YAML for a ConfigMap:
Table: Creation Methods at a Glance

How to consume a ConfigMap in a Pod

  • Environment variables using envFrom (imports all keys as env vars):
  • Single env var from a specific key (explicit mapping):
  • Mount as a volume (expose keys as files at mountPath):
Notes on consumption
  • Environment injection reads values as strings (no types).
  • When mounted as files, each key becomes a file with the key name and the file contents equal to the key’s value.
  • Updates to ConfigMaps will reflect in environment variables only after Pod restart; mounted volumes can reflect updates automatically depending on kubelet sync behavior.

Summary

  • ConfigMaps store non-sensitive configuration as key-value pairs and are namespaced Kubernetes resources.
  • Create them declaratively (recommended) or imperatively for quick tasks.
  • Consume ConfigMaps as environment variables (env, envFrom) or mounted files (volumes).
  • Use Kubernetes Secrets (not ConfigMaps) for sensitive data and protect secrets using RBAC and encryption-at-rest.

Watch Video