ConfigMap
A ConfigMap is a Kubernetes object that stores non-confidential configuration data in key-value pairs.
It lets you decouple environment-specific config (like database URLs, feature flags, API endpoints) from your container images and Pods.
ConfigMaps are for non-sensitive data.
For secrets (passwords, API keys, TLS certs), use Secrets, not ConfigMaps.
ConfigMaps can be updated, but Pods don’t automatically reload the new config unless:
The app watches the config files, OR
You restart the Pods.
Commands
Create ConfigMap from literal values:
kubectl create configmap <configmap-name> \
--from-literal=node_env=production \
--from-literal=port=8000Create ConfigMap from a file:
Example
How to use in Deployment example 1 (Individual env variables):
How to use in Deployment example 2 (Whole env file):
How to use in Deployment example 3 (Injected as a volume):
Last updated