DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Kubernetes Tutorial

Introduction to Kubernetes
Kubernetes Architecture
Installing Kubernetes
kubectl Basics
Kubernetes Pods
Kubernetes Deployments
Kubernetes Services
ConfigMaps and Secrets
Kubernetes Storage
Kubernetes Namespaces
Kubernetes Resource Management
Helm for Kubernetes
Kubernetes Monitoring

Kubernetes ConfigMaps

PreviousPrev
Next

Create ConfigMaps from literals, files, or YAML and use them as environment variables or mounted configuration files.

What Is a ConfigMap?

A ConfigMap stores non-sensitive configuration data so applications can read settings at runtime instead of hardcoding them into images.

Create a ConfigMap from Literals

kubectl create configmap app-config   --from-literal=APP_ENV=dev   --from-literal=LOG_LEVEL=info

Create a ConfigMap from a File

kubectl create configmap nginx-config --from-file=nginx.conf

Create a ConfigMap from YAML

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  APP_ENV: dev
  LOG_LEVEL: info

Use as Environment Variables with envFrom

apiVersion: v1
kind: Pod
metadata:
  name: env-config-demo
spec:
  containers:
    - name: app
      image: busybox:1.36
      command: ['sh', '-c', 'env | grep APP_ && sleep 3600']
      envFrom:
        - configMapRef:
            name: app-config

Use a Single Key with valueFrom

apiVersion: v1
kind: Pod
metadata:
  name: single-key-demo
spec:
  containers:
    - name: app
      image: busybox:1.36
      command: ['sh', '-c', 'echo $LOG_LEVEL && sleep 3600']
      env:
        - name: LOG_LEVEL
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: LOG_LEVEL

Use as Mounted Files

apiVersion: v1
kind: Pod
metadata:
  name: file-config-demo
spec:
  volumes:
    - name: config-volume
      configMap:
        name: app-config
  containers:
    - name: app
      image: busybox:1.36
      command: ['sh', '-c', 'ls /config && sleep 3600']
      volumeMounts:
        - name: config-volume
          mountPath: /config

Inspect ConfigMaps

kubectl get cm
kubectl describe cm app-config

Why Two Consumption Patterns Exist

Environment variables are simple for app settings. Mounted files are better when the app expects actual config files.

Exercise

ConfigMap Use

What should ConfigMaps usually store?

Exercise

File Mount Pattern

Why might you mount a ConfigMap as files instead of using environment variables?

PreviousPrev
Next

Continue Learning

Kubernetes Service: LoadBalancer

Learn how LoadBalancer Services provision cloud load balancers, what EXTERNAL-IP means, and when they are a better fit than NodePort.

18 min·Easy

Kubernetes Ingress

Route HTTP and HTTPS traffic into your cluster with Ingress rules, controllers, TLS termination, and host or path based routing.

22 min·Easy

ConfigMaps and Secrets

Learn why configuration should live outside images and how ConfigMaps and Secrets help separate code from runtime settings.

15 min·Easy

Explore Related Topics

Do

Docker Tutorials

Build the containers Kubernetes orchestrates

Te

Terraform Tutorials

Provision Kubernetes clusters as code

Try the Tool

YAML Validator

Validate Kubernetes manifests and any YAML files instantly.

On This Page

What Is a ConfigMap?Create a ConfigMap from LiteralsCreate a ConfigMap from a FileCreate a ConfigMap from YAMLUse as Environment Variables with `envFrom`Use a Single Key with `valueFrom`Use as Mounted FilesInspect ConfigMapsWhy Two Consumption Patterns Exist