What is the Kubernetes ConfigMap Object

The purpose of the ConfigMap object is to store non-sensitive data in key-value pairs. This makes reusing of configuration easy because the configuration is separated from the containers.

Creating ConfigMaps

There are two ways to create ConfigMaps.

Declarative

apiVersion: v1
kind: ConfigMap
metadata:
  name: name-of-config-map
data:
  name: Ali
  age: '19'

Imperative

kubectl create config-map name-of-config-map --from-literal=ENV_1=VALUE_1 --from-literal=ENV_2=VALUE_2

Making use of a ConfigMap from within a Pod definition file

apiVersion: v1
kind: Pod
metadata:
  name: name-of-pod
spec:
  containers:
    - name: name-of-container
      envFrom:
        - configMapRef:
            name: name-of-config-map

Resources

No Comments Yet