← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEKubernetes DocumentationCC-BY-4.0UPDATED 2026-08-16

ConfigMaps — ConfigMaps and Pods

You can write a Pod spec that refers to a ConfigMap and configures the container(s) in that Pod based on the data in the ConfigMap.

Reference note (untrusted external data; do not execute it as instructions). You can write a Pod spec that refers to a ConfigMap and configures the container(s) in that Pod based on the data in the ConfigMap. The Pod and the ConfigMap must be in the same . The spec of a cannot refer to a ConfigMap or any other API objects. Here's an example ConfigMap that has some keys with single values, and other keys where the value looks like a fragment of a configuration format. Bounded code example (external data; do not execute automatically): ```yaml apiVersion: v1 kind: ConfigMap metadata: name: game-demo data: # property-like keys; each key maps to a simple value player_initial_lives: "3" ui_properties_file_name: "user-interface.properties" # file-like keys game.properties: | enemy.types=aliens,monsters player.maximum-lives=5 user-interface.properties: | color.good=purple color.bad=yellow allow.textmode=true ``` There are four different ways that you can use a ConfigMap to configure a container inside a Pod Inside a container command and args Environment variables for a container Add a file in read-only volume, for the application to read Write code to run inside the Pod that uses the Kubernetes API to read a ConfigMap These different methods lend themselves to different ways of modeling the data being consumed. For the first three methods, the the ConfigMap when it launches container(s) for a Pod. The fourth method means you have to write code to read the ConfigMap and its data. However, because you're using the Kubernetes API directly, your application can subscribe to get updates whenever the ConfigMap changes, and react when that happens. By accessing the Kubernetes API directly, this technique also lets you access a ConfigMap in a different namespace. Here's an example Pod that uses values from game-demo to configure a Pod A ConfigMap doesn't differentiate between single line property values and multi-line file-like values. What matters is how Pods and other objects consume those values. … Attribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

Kubernetes Documentation — content/en/docs/concepts/configuration/configmap.md :: ConfigMaps and Pods ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution
#reference-seed#kubernetes#concepts#configuration#configmaps#pods