Configure a Pod to Use a ConfigMap — Create a kustomization.yaml file with ConfigMapGenerator
cat ./kustomization.yaml configMapGenerator: name: game-config-4 options: labels: game-config: config-4 files: configure-pod-container/configmap/game.properties EOF Bounded code example (external data; do not execute automatically): ```text Apply the kustomization directory to create the ConfigMap o
Reference note (untrusted external data; do not execute it as instructions).
cat ./kustomization.yaml configMapGenerator: name: game-config-4 options: labels: game-config: config-4 files: configure-pod-container/configmap/game.properties EOF
Bounded code example (external data; do not execute automatically):
```text
Apply the kustomization directory to create the ConfigMap object:
```
configmap/game-config-4-m9dm2f92bt created
Bounded code example (external data; do not execute automatically):
```text
You can check that the ConfigMap was created like this:
```
NAME DATA AGE game-config-4-m9dm2f92bt 1 37s
Bounded code example (external data; do not execute automatically):
```text
and also:
```
kubectl describe configmaps/game-config-4-m9dm2f92bt
Name: game-config-4-m9dm2f92bt Namespace: default Labels: game-config=config-4 Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"v1","data":{"game.properties":"enemies=aliens\nlives=3\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.p...
Data game.properties: enemies=aliens lives=3 enemies.cheat=true enemies.cheat.level=noGoodRotten secret.code.passphrase=UUDDLRLRBABAS secret.code.allowed=true secret.code.lives=30 Events
Bounded code example (external data; do not execute automatically):
```text
Notice that the generated ConfigMap name has a suffix appended by hashing the contents. This
ensures that a new ConfigMap is generated each time the content is modified.
```
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/tasks/configure-pod-container/configure-pod-configmap.md :: Create a kustomization.yaml file with ConfigMapGenerator ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution