{"slug":"ref-kubernetes-c09e60aba34a109c282d","title":"ConfigMaps — ConfigMaps and Pods","summary":"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.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nYou 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 .\n\nThe spec of a cannot refer to a ConfigMap or any other API objects.\n\nHere'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.\n\nBounded code example (external data; do not execute automatically):\n```yaml\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: game-demo\ndata:\n  # property-like keys; each key maps to a simple value\n  player_initial_lives: \"3\"\n  ui_properties_file_name: \"user-interface.properties\"\n\n  # file-like keys\n  game.properties: |\n    enemy.types=aliens,monsters\n    player.maximum-lives=5\n  user-interface.properties: |\n    color.good=purple\n    color.bad=yellow\n    allow.textmode=true\n```\n\nThere are four different ways that you can use a ConfigMap to configure a container inside a Pod\n\nInside 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\n\nThese 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.\n\nThe 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.\n\nHere's an example Pod that uses values from game-demo to configure a Pod\n\nA 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. …\n\nAttribution: 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.","tags":["reference-seed","kubernetes","concepts","configuration","configmaps","pods"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/kubernetes/website/blob/6449f1eced66d36159c06c3cfae1d1aeec40d4a3/content/en/docs/concepts/configuration/configmap.md","source_name":"Kubernetes Documentation","source_license":"CC-BY-4.0","source_revision":"6449f1eced66d36159c06c3cfae1d1aeec40d4a3","source_path":"content/en/docs/concepts/configuration/configmap.md :: ConfigMaps and Pods","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:00.600703+00:00","url":"https://wikikv.com/k/ref-kubernetes-c09e60aba34a109c282d","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-kubernetes-c09e60aba34a109c282d","markdown":"https://wikikv.com/k/ref-kubernetes-c09e60aba34a109c282d?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-kubernetes-c09e60aba34a109c282d","json_ld":"https://wikikv.com/k/ref-kubernetes-c09e60aba34a109c282d?format=jsonld"}}