From 6d0f8be9bc51e7e3fc604845a13048d06a6c2f17 Mon Sep 17 00:00:00 2001 From: Rishit Dagli Date: Mon, 24 Oct 2022 18:35:48 +0000 Subject: [PATCH] Update example to configure pods --- .../docs/concepts/configuration/configmap.md | 41 +------------------ .../en/examples/configmap/configure-pod.yaml | 39 ++++++++++++++++++ 2 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 content/en/examples/configmap/configure-pod.yaml diff --git a/content/en/docs/concepts/configuration/configmap.md b/content/en/docs/concepts/configuration/configmap.md index 4f5ace4348801..4bd3ac32f120a 100644 --- a/content/en/docs/concepts/configuration/configmap.md +++ b/content/en/docs/concepts/configuration/configmap.md @@ -111,46 +111,7 @@ 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: -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: configmap-demo-pod -spec: - containers: - - name: demo - image: alpine - command: ["sleep", "3600"] - env: - # Define the environment variable - - name: PLAYER_INITIAL_LIVES # Notice that the case is different here - # from the key name in the ConfigMap. - valueFrom: - configMapKeyRef: - name: game-demo # The ConfigMap this value comes from. - key: player_initial_lives # The key to fetch. - - name: UI_PROPERTIES_FILE_NAME - valueFrom: - configMapKeyRef: - name: game-demo - key: ui_properties_file_name - volumeMounts: - - name: config - mountPath: "/config" - readOnly: true - volumes: - # You set volumes at the Pod level, then mount them into containers inside that Pod - - name: config - configMap: - # Provide the name of the ConfigMap you want to mount. - name: game-demo - # An array of keys from the ConfigMap to create as files - items: - - key: "game.properties" - path: "game.properties" - - key: "user-interface.properties" - path: "user-interface.properties" -``` +{{< codenew file="configmap/configure-pod.yaml" >}} A ConfigMap doesn't differentiate between single line property values and multi-line file-like values. diff --git a/content/en/examples/configmap/configure-pod.yaml b/content/en/examples/configmap/configure-pod.yaml new file mode 100644 index 0000000000000..1b31d0b2aff13 --- /dev/null +++ b/content/en/examples/configmap/configure-pod.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: Pod +metadata: + name: configmap-demo-pod +spec: + containers: + - name: demo + image: alpine + command: ["sleep", "3600"] + env: + # Define the environment variable + - name: PLAYER_INITIAL_LIVES # Notice that the case is different here + # from the key name in the ConfigMap. + valueFrom: + configMapKeyRef: + name: game-demo # The ConfigMap this value comes from. + key: player_initial_lives # The key to fetch. + - name: UI_PROPERTIES_FILE_NAME + valueFrom: + configMapKeyRef: + name: game-demo + key: ui_properties_file_name + volumeMounts: + - name: config + mountPath: "/config" + readOnly: true + volumes: + # You set volumes at the Pod level, then mount them into containers inside that Pod + - name: config + configMap: + # Provide the name of the ConfigMap you want to mount. + name: game-demo + # An array of keys from the ConfigMap to create as files + items: + - key: "game.properties" + path: "game.properties" + - key: "user-interface.properties" + path: "user-interface.properties" + \ No newline at end of file