-e pattern.

Quick comparison: Docker vs Kubernetes
When running a container locally with Docker you can pass environment variables using-e:
env (or envFrom) fields.
Use
env for individual variables (static or referenced), and envFrom to import all keys from a ConfigMap or Secret. The same env configuration works inside any workload that has a containers spec (Pod, Deployment, ReplicaSet, etc.).Basic example — key/value in a Pod manifest
Add anenv array to the container spec. Each item uses name and value. This example shows a direct, static environment variable:
envis an array, so each environment variable is prefixed with-.- The same
enventries can be put into acontainersentry inside a Deployment manifest.
Referencing ConfigMaps and Secrets
Instead of hardcoding values, reference keys from a ConfigMap or Secret usingvalueFrom. This is the preferred pattern for separating configuration and secrets from container images.
Example referencing a key from a ConfigMap:
Importing all keys with envFrom
If you want to expose every key from a ConfigMap or Secret as environment variables, useenvFrom. This will create one environment variable per key in the referenced object.
When to use each approach
Security reminder
Secrets in Kubernetes are base64-encoded, not encrypted by default (see Kubernetes documentation: https://kubernetes.io/docs/concepts/configuration/secret/). Treat them as sensitive and consider using appropriate secrets management (encryption at rest, RBAC controls, or external secret stores) for production workloads.
Links and references
- Kubernetes ConfigMap: https://kubernetes.io/docs/concepts/configuration/configmap/
- Kubernetes Secret: https://kubernetes.io/docs/concepts/configuration/secret/
- Kubernetes Pods and Containers: https://kubernetes.io/docs/concepts/workloads/pods/
envFrom.