Filesystem projection
Keys become files inside a mounted directory such as /etc/config.
Mount ConfigMap keys as files so applications can read runtime configuration from the filesystem.
Keys become files inside a mounted directory such as /etc/config.
The image stays the same while the runtime configuration changes per environment.
Use ConfigMaps for non-sensitive data and Secrets for passwords, tokens, and certificates.
Store settings as named keys in a ConfigMap resource.
The Deployment or Pod references the ConfigMap in the volumes section.
Kubernetes projects the ConfigMap into a mount path as regular files.
The process loads its configuration from the mounted path rather than from baked-in defaults.
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
database_url: jdbc:mysql://localhost:3306/mydb
log_level: info
apiVersion: apps/v1
kind: Deployment
metadata:
name: configmap-deployment
spec:
template:
spec:
containers:
- name: app
image: nginx
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: app-config
| Pattern | How Data Appears | Best Fit |
|---|---|---|
| Environment variables | Process environment entries | Simple startup settings |
| ConfigMap volume | Files in a mounted directory | Apps expecting config files or templates |
| Secret volume | Sensitive files in a mounted directory | Credentials and keys |
Project NGINX or Apache config snippets without rebuilding the image.
Mount different data for dev, test, and prod while keeping the same container image.
Mounted files make it easy to confirm what configuration the container can actually see.