ConfigMaps allows creating data objects that can be consumed by Pods at runtime.
The data in ConfigMaps is stored as key-value entries:
-
Key: is a string value formed by alphanumeric, dot (.), dash (-), and underscore (_) characters.
-
Value: is a string value that can contain any character, including carriage returns (if multiple lines then the data must be indented properly).
The key and the value, in the ConfigMap, are separated with a colon (
key:value).
The name of the ConfigMap must be a valid DNS subdomain name.
Examples of values that can be saved in ConfigMaps include:
-
Application settings.
-
Configuration files (json/xml/properties files, shell scripts, ...).
-
Base64 encoded data.
ConfigMaps are not meant to store sensitive data (credentials, certificates, ...).
Kubernetes Secrets should be used instead.
The data stored in a ConfigMap can be consumed in a container in one the following ways:
-
Environment variables.
-
Command-line arguments of the container command.
-
Files in volumes.
-
Custom code (read the ConfigMap directly from the Kubernetes API).
Note:
If you update a ConfigMap that was already posted to the Kubernetes API server,
then containers that were already created will be able to leverage the new data only if it was injected as files in a volume.
ConfigMap data injected as environment variables won't be updated in a running container.