You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/tasks/configure-pod-container/configure-pod-configmap.md
+5-8Lines changed: 5 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -657,7 +657,7 @@ data:
657
657
658
658
### Restrictions
659
659
660
-
- You must create a ConfigMapbefore referencing it in a Pod specification, or mark the ConfigMap as "optional" (see [Optional ConfigMaps](#optional-configmaps)). If you reference a ConfigMap that doesn't exist, or hasn't been marked as "optional" the Pod won't start. Likewise, references to keys that don't exist in the ConfigMap will prevent the pod from starting.
660
+
- You must create the `ConfigMap` object before you reference it in a Pod specification. Alternatively, mark the ConfigMap reference as `optional` in the Pod spec (see [Optional ConfigMaps](#optional-configmaps)). If you reference a ConfigMap that doesn't exist and you don't mark the reference as `optional`, the Pod won't start. Similarly, references to keys that don't exist in the ConfigMap will also prevent the Pod from starting, unless you mark the key references as `optional`.
661
661
662
662
- If you use `envFrom` to define environment variables from ConfigMaps, keys that are considered invalid will be skipped. The pod will be allowed to start, but the invalid names will be recorded in the event log (`InvalidVariableNames`). The log message lists each skipped key. For example:
663
663
@@ -677,15 +677,11 @@ data:
677
677
678
678
### Optional ConfigMaps
679
679
680
-
In a Pod, or pod template, you can mark a reference to a ConfigMap as _optional_.
681
-
If the ConfigMap is non-existent, the configuration for which it provides data in the Pod (e.g. environment variable, mounted volume) will be empty.
680
+
You can mark a reference to a ConfigMap as _optional_ in a Pod specification.
681
+
If the ConfigMap doesn't exist, the configuration for which it provides data in the Pod (e.g. environment variable, mounted volume) will be empty.
682
682
If the ConfigMap exists, but the referenced key is non-existent the data is also empty.
683
683
684
-
#### Optional ConfigMap in environment variables
685
-
686
-
There might be situations where environment variables are not always required.
687
-
You can mark an environment variables for a container as optional,
688
-
like this:
684
+
For example, the following Pod specification marks an environment variable from a ConfigMap as optional:
689
685
690
686
```yaml
691
687
apiVersion: v1
@@ -734,6 +730,7 @@ spec:
734
730
name: no-config
735
731
optional: true # mark the source ConfigMap as optional
0 commit comments