Many applications require configuration using some combination of configuration
files, command line arguments, and environment variables. These configuration
artifacts should be decoupled from image content in order to keep containerized
applications portable.
The ConfigMap
object provides mechanisms to inject containers with
configuration data while keeping containers agnostic of OpenShift Origin. A
ConfigMap
can be used to store fine-grained information like individual
properties or coarse-grained information like entire configuration files or JSON
blobs.
The ConfigMap
API 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. ConfigMap
is similar to
secrets, but designed to more conveniently
support working with strings that do not contain sensitive information.
Example 1. ConfigMap Object Definition
kind: ConfigMap
apiVersion: v1
metadata:
creationTimestamp: 2016-02-18T19:14:38Z
name: example-config
namespace: default
data: (1)
example.property.1: hello
example.property.2: world
example.property.file: |-
property.1=value-1
property.2=value-2
property.3=value-3
1 |
Contains the configuration data. |
Configuration data can be consumed in pods in a variety of ways. A ConfigMap
can be used to:
-
Populate the value of environment variables.
-
Set command-line arguments in a container.
-
Populate configuration files in a volume.
Both users and system components may store configuration data in a
ConfigMap
.