Environment Variables and Config Injection
Environment variables in Kubernetes allow you to inject configuration values into containers at runtime.
Static Environment Variables:
env:
- name: ENVIRONMENT
value: production
Dynamic from ConfigMaps:
env:
- name: APP_MODE
valueFrom:
configMapKeyRef:
name: app-config
key: APP_MODE
Dynamic from Secrets:
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: password
Injecting configs this way keeps your application code clean and your configurations centralized.