ConfigMaps and Secrets
Configurations & Secrets Matter
Picture a spacecraft. The engines (containers) provide thrust, but without navigation data (configuration) and secure access codes (secrets), the mission fails. Kubernetes pods face the same challenge: they need configuration data to run correctly and secrets to access sensitive systems. Hard‑coding these values inside containers is risky and inflexible.
Kubernetes introduced ConfigMaps and Secrets as the navigation charts and access codes of clusters, separating configuration and sensitive data from application logic.
ConfigMaps – Navigation Charts
- Definition: ConfigMaps store non‑sensitive configuration data as key‑value pairs.
- Use Cases:
- Environment variables (e.g. API endpoints).
- Configuration files (e.g. app settings).
- Command‑line arguments.
- Injection Methods:
- As environment variables.
- As mounted volumes.
- Analogy: ConfigMaps are like navigation charts - guiding containers without embedding data inside them.
Secrets – Access Codes
- Definition: Secrets store sensitive data (passwords, tokens, certificates) in base64‑encoded form.
- Use Cases:
- Database credentials.
- API keys.
- TLS certificates.
- Security: Secrets are encrypted at rest and transmitted securely.
- Analogy: Secrets are like access codes - granting secure entry to restricted systems.
Global Context
- Enterprises: Use ConfigMaps and Secrets to manage configuration across microservices securely.
- Cloud Providers: Managed Kubernetes services integrate Secrets with cloud KMS (Key Management Systems).
- Community: ConfigMaps and Secrets are taught worldwide as best practices for secure, flexible configuration.
Hands‑On Exercise
- Reflect: How do ConfigMaps and Secrets decouple configuration and sensitive data from application logic?
Use them in a pod:
apiVersion: v1
kind: Pod
metadata:
name: config-secret-demo
spec:
containers:
- name: app
image: nginx
env:
- name: APP_MODE
valueFrom:
configMapKeyRef:
name: app-config
key: APP_MODE
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: DB_PASSWORD
kubectl apply -f pod.yaml
kubectl exec -it config-secret-demo -- printenv | grep APP_MODE
Create a Secret:
kubectl create secret generic db-secret --from-literal=DB_PASSWORD=supersecure
kubectl get secrets
Create a ConfigMap:
kubectl create configmap app-config --from-literal=APP_MODE=production
kubectl get configmaps
The Hacker’s Notebook
- ConfigMaps are charts - guiding containers with flexible configuration.
- Secrets are codes - protecting sensitive data with encryption.
- Lesson for engineers: Don’t hard‑code values - externalize them with ConfigMaps and Secrets.
- Hacker’s mindset: Treat configuration and secrets as your control levers. With them, you can run secure, adaptable workloads across clusters.

Updated on Dec 29, 2025