Using ConfigMaps
ConfigMaps allow you to decouple configuration artifacts from container images, making your applications more portable and easier to manage.
Ways to Create ConfigMaps:
- From literal values
- From files
- From directories
Example (from literal):
kubectl create configmap app-config --from-literal=APP_MODE=production
Example Pod using ConfigMap:
env:
- name: APP_MODE
valueFrom:
configMapKeyRef:
name: app-config
key: APP_MODE
ConfigMaps can also be mounted as volumes into containers, making them flexible for various use cases.