@@ -126,25 +126,32 @@ spec:
126
126
configMap:
127
127
# Provide the name of the ConfigMap you want to mount.
128
128
name: game-demo
129
+ # An array of keys from the ConfigMap to create as files
130
+ items:
131
+ - key: "game.properties"
132
+ path: "game.properties"
133
+ - key: "user-interface.properties"
134
+ path: "user-interface.properties"
129
135
` ` `
130
136
131
137
132
138
A ConfigMap doesn't differentiate between single line property values and
133
139
multi-line file-like values.
134
140
What matters is how Pods and other objects consume those values.
141
+
135
142
For this example, defining a volume and mounting it inside the `demo`
136
- container as `/config` creates four files :
143
+ container as `/config` creates two files,
144
+ ` /config/game.properties` and `/config/user-interface.properties`,
145
+ even though there are four keys in the ConfigMap. This is because the Pod
146
+ definition specifies an `items` array in the `volumes` section.
147
+ If you omit the `items` array entirely, every key in the ConfigMap becomes
148
+ a file with the same name as the key, and you get 4 files.
137
149
138
- - ` /config/player_initial_lives`
139
- - ` /config/ui_properties_file_name`
140
- - ` /config/game.properties`
141
- - ` /config/user-interface.properties`
150
+ # # Using ConfigMaps
142
151
143
- If you want to make sure that `/config` only contains files with a
144
- ` .properties` extension, use two different ConfigMaps, and refer to both
145
- ConfigMaps in the `spec` for a Pod. The first ConfigMap defines
146
- ` player_initial_lives` and `ui_properties_file_name`. The second
147
- ConfigMap defines the files that the kubelet places into `/config`.
152
+ ConfigMaps can be mounted as data volumes. ConfigMaps can also be used by other
153
+ parts of the system, without being directly exposed to the Pod. For example,
154
+ ConfigMaps can hold data that other parts of the system should use for configuration.
148
155
149
156
{{< note >}}
150
157
The most common way to use ConfigMaps is to configure settings for
@@ -157,12 +164,6 @@ or {{< glossary_tooltip text="operators" term_id="operator-pattern" >}} that
157
164
adjust their behavior based on a ConfigMap.
158
165
{{< /note >}}
159
166
160
- # # Using ConfigMaps
161
-
162
- ConfigMaps can be mounted as data volumes. ConfigMaps can also be used by other
163
- parts of the system, without being directly exposed to the Pod. For example,
164
- ConfigMaps can hold data that other parts of the system should use for configuration.
165
-
166
167
# ## Using ConfigMaps as files from a Pod
167
168
168
169
To consume a ConfigMap in a volume in a Pod :
0 commit comments