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.

Commands

Create ConfigMap from literal values:

kubectl create configmap <configmap-name> \
  --from-literal=node_env=production \
  --from-literal=port=8000

Create 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