ConfigMaps & App Config

A ConfigMap is a Kubernetes API object used to store non-confidential configuration data in key-value pairs, decoupling container images from environment configurations.

1. Creating a ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  LOG_LEVEL: "debug"
  MAX_CONNECTIONS: "100"
  APP_THEME: "dark"

2. Injecting ConfigMap into Pod Containers

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-app
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: app
          image: my-app:latest
          # Load ALL key-value pairs from ConfigMap as Environment Variables!
          envFrom:
            - configMapRef:
                name: app-config

Next Up

Learn Kubernetes Secrets: storing sensitive passwords, API keys, Base64 encoding, and TLS certificates.

Next Lesson: Secrets & Sensitive Data →