https://drive.google.com/file/d/186ta4j4uZBZyg3jlWT100rieeXzVDV22/view?usp=sharing

๐ŸŽฏ What It Is

A ConfigMap is a Kubernetes resource that stores non-sensitive configuration data (like app settings, feature flags, log levels) as key-value pairs โ€” separate from your container image.

โœ… Why? So you can change config without rebuilding your image.

๐Ÿ’ก Real-World Analogy

Think of a ConfigMap like a .env file or app.conf โ€” but managed by Kubernetes and injected into your Pods safely.


๐Ÿงช Example: Inject App Settings as Environment Variables

Step 1: Create a ConfigMap

# app-config.yaml
apiVersion: v1
kind: ConfigMap
meta
  name: webapp-config
  namespace: dev
data:
  LOG_LEVEL: "info"
  FEATURE_NEW_UI: "true"
  API_TIMEOUT: "5000"

Apply it:

kubectl apply -f app-config.yaml

Step 2: Use It in a Pod

# webapp-pod.yaml
apiVersion: v1
kind: Pod
meta
  name: webapp
  namespace: dev
spec:
  containers:
  - name: app
    image: nginx
    envFrom:
    - configMapRef:
        name: webapp-config  # โ† Inject all keys as env vars

Apply and test:

kubectl apply -f webapp-pod.yaml
kubectl exec webapp -n dev -- printenv | grep LOG_LEVEL
# Output: LOG_LEVEL=info

โœ… Result: Your app reads config from environment โ€” no hardcoded values!


โœ… Summary YAML