K8s by Example: ConfigMaps
| ConfigMaps store non-sensitive configuration as key-value pairs. They decouple configuration from container images. Inject them as environment variables or mount as files. Never store secrets here. |
| configmap.yaml | |
| ConfigMaps use the core | |
| configmap-file.yaml | |
| Store multi-line config files using literal block syntax ( | |
| pod-envfrom.yaml | |
| Inject all keys as environment variables with | |
| pod-env-valueFrom.yaml | |
| Select specific keys with | |
| pod-volume-mount.yaml | |
| Mount ConfigMap as files in a volume. Each key becomes a file. Mounted ConfigMaps auto-update when changed (within ~1 minute). Use | |
| configmap-immutable.yaml | |
| Immutable ConfigMaps cannot be changed after creation. This improves performance (no watches) and prevents accidental changes. You must delete and recreate to update. | |
| terminal | |
| Create ConfigMaps imperatively from literals, files, directories, or env files. The | |
| terminal | |
| ConfigMap updates with mounted volumes propagate automatically. Env vars never update, so a Pod restart is required. Use rollout restart or tools like Reloader for auto-restart. | |