Config maps allow you to decouple configuration artifacts from image content to keep containerized applications portable. The following sections define config maps and how to create and use them.
Many applications require configuration by using some combination of configuration files, command-line arguments, and environment variables. In OpenShift Container Platform, these configuration artifacts are decoupled from image content to keep containerized applications portable.
The ConfigMap
object provides mechanisms to inject containers with configuration data while keeping containers agnostic of OpenShift Container Platform. A config map can be used to store fine-grained information like individual properties or coarse-grained information like entire configuration files or JSON blobs.
The ConfigMap
object holds key-value pairs of configuration data that can be consumed in pods or used to store configuration data for system components such as controllers. For example:
Note: You can use the binaryData
field when you create a config map from a binary file, such as an image.
Configuration data can be consumed in pods in a variety of ways. A config map can be used to:
Users and system components can store configuration data in a config map. A config map is similar to a secret, but designed to more conveniently support working with strings that do not contain sensitive information.
ConfigMap
objects reside in a project.--manifest-url
flag, its --config
flag, or its REST API because these are not common ways to create pods.Feature | ConfigMap | Secret |
---|---|---|
Data Type | Non-sensitive | Sensitive (e.g., passwords) |
Encoding | Plaintext | Base64-encoded |
Use Cases | Configs, flags | Passwords, tokens |
Go to Container Platform.
In the left sidebar, click Configuration > ConfigMap.
Click Create ConfigMap.
Refer to the instructions below to configure the relevant parameters.
Parameter | Description |
---|---|
Entries | Refers to key:value pairs, supporting both Add and Import methods.
|
Binary Entries | Refers to binary files not larger than 1M. The file name will be used as the key, and the file content will be used as the value, filled into a configuration item. Note: After creating a ConfigMap, the imported files cannot be modified. |
Example of Bulk Add Format:
Click Create.
Or from a file:
You can click the (⋮) on the right side of the list page or click Actions in the upper right corner of the detail page to update or delete the ConfigMap as needed.
Changes to the ConfigMap will affect the workloads that reference the configuration, so please read the operation instructions in advance.
Operations | Description |
---|---|
Update |
|
Delete | After deleting a ConfigMap, workloads that have referenced this ConfigMap (or its configuration items) through environment variables may be adversely affected during Pod creation if they are rebuilt and cannot find the reference source. |
Each key becomes an environment variable in the container.
Each key is a file under /etc/config
, and the file content is the value.
Feature | ConfigMap | Secret |
---|---|---|
Data Type | Non-sensitive | Sensitive (e.g., passwords) |
Encoding | Plaintext | Base64-encoded |
Use Cases | Configs, flags | Passwords, tokens |