Container Environment Variable Sources

Container Environment Variable Sources An architecture diagram generated by Archify. Pod · Pod · Architecture component Pod Pod Container · Receives the environment variables · Architecture component Container Receives the environment variables Direct Setting · env name/value · Environment Variable Sources Direct Setting env name/value ConfigMap · Non-sensitive config · Environment Variable Sources ConfigMap Non-sensitive config Secret · Sensitive data · Environment Variable Sources Secret Sensitive data Downward API · Pod / container info · Environment Variable Sources Downward API Pod / container info Contains env valueFrom.configMapKeyRef · envFrom.configMapRef valueFrom.secretKeyRef · envFrom.secretRef valueFrom.fieldRef · resourceFieldRef Environment Variable Sources Legend Workload Environment variable source Secret (sensitive data)

Supplying the value directly

  • • Direct Setting: give the env entry a fixed name and value string
  • • Downward API: fieldRef exposes Pod fields such as metadata.name; resourceFieldRef exposes container resource values such as requests.cpu

Referencing another resource

  • • ConfigMap: valueFrom.configMapKeyRef (one key) or envFrom.configMapRef (all keys)
  • • Secret: valueFrom.secretKeyRef (one key) or envFrom.secretRef (all keys)
  • • All four sources end up as environment variables inside the Container