Kubernetes Tutorial — Part 5: ConfigMaps, Secrets, and Environment Config

By Suraj Ahir March 17, 2026 7 min read

← Part 4 Kubernetes Tutorial · Part 5 of 12 Part 6 →
Kubernetes - ConfigMaps
Kubernetes - ConfigMaps

Hardcoding configuration into container images is a common beginner mistake. Database hostnames, API keys, feature flags — none of this belongs in your Docker image. Kubernetes provides ConfigMaps for non-sensitive data and Secrets for sensitive data.

configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  DB_HOST: "postgres-service"
  DB_PORT: "5432"
  LOG_LEVEL: "info"
Creating Secrets
kubectl create secret generic db-credentials \
  --from-literal=username=admin \
  --from-literal=password=s3cur3-pass

Never commit secrets to Git. Never log them. Never print them in error messages. The number of production breaches caused by leaked credentials is staggering.

In Part 6, we cover persistent storage for databases and stateful applications.

← Part 4 Kubernetes Tutorial · Part 5 of 12 Part 6 →
← Back to Blog
Disclaimer: This content is for educational purposes only. SRJahir Tech does not guarantee any specific outcome, job placement, or exam result. Learning requires consistent effort and practical application.