ConfigMaps and Secrets

Inject configuration and credentials without rebuilding images.

  • configmap
  • kubernetes secret
  • kubectl create secret
  • env config
  • etcd encryption

ConfigMaps and Secrets

Inject configuration and credentials without rebuilding images.

Commands

CommandWhat it does
kubectl create cm app-cfg --from-literal=LOG_LEVEL=infoLiteral ConfigMap
kubectl create secret generic api-keys --from-literal=TOKEN=xxxOpaque secret
kubectl get cm,secretList both kinds together
kubectl describe secret api-keysMetadata only (values stay hidden)
kubectl set env deploy/api --from=configmap/app-cfgWire config into a workload

Example

kubectl create cm app-cfg --from-literal=LOG_LEVEL=info
kubectl create secret generic api-keys --from-literal=TOKEN=s3cret
kubectl set env deploy/api --from=configmap/app-cfg --from=secret/api-keys

FAQ

Are Secrets encrypted?

Only base64-encoded by default โ€” enable etcd encryption at rest plus RBAC, or use an external secret manager.

env vs volume mounts?

Env is simple; volume mounts update without pod restarts and suit large config files.

FAQ

Are Secrets encrypted?
Only base64-encoded by default โ€” enable etcd encryption at rest plus RBAC, or use an external secret manager.
env vs volume mounts?
Env is simple; volume mounts update without pod restarts and suit large config files.

Kubernetes