How do you hot-reload application configurations when ConfigMaps update?
❓ Interview Prompt: Explain ConfigMap volume projection file updates, propagation delay, and tools like Reloader for automatic pod restarts on ConfigMap changes.
When a ConfigMap is updated, pods consuming it via volume mounts eventually receive the updated files — but the propagation is not instant and the application must support file-watching to use the new config.
ConfigMap Update Propagation:
--sync-frequency). The files in the mounted directory are atomically replaced using symlinks.Application File-Watching (Native Reload):
Applications using config file watching (e.g., NGINX, Prometheus, Node.js with chokidar) can pick up changes without pod restarts. However, most applications require a process restart to reload config.
Reloader (Stakater):
Reloader is a Kubernetes controller that watches ConfigMaps and Secrets and automatically performs rolling restarts on Deployments/StatefulSets when those objects change.
Simply add an annotation to your Deployment — Reloader handles the rest.
Code Implementation Example
# ConfigMap with application config
apiVersion: v1
kind: ConfigMap
metadata:
name: api-config
data:
app.json: |
{
"logLevel": "info",
"featureFlags": {
"newCheckout": true
}
}
---
# Deployment with Reloader annotation
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
annotations:
# Reloader watches this ConfigMap and restarts pods on change
reloader.stakater.com/auto: "true"
# OR specify exact ConfigMaps to watch:
# configmap.reloader.stakater.com/reload: "api-config,api-secrets"
spec:
template:
spec:
containers:
- name: api
image: myapp:v1.2.3
# Mount ConfigMap as volume — receives file updates
volumeMounts:
- name: config
mountPath: /app/config
readOnly: true
volumes:
- name: config
configMap:
name: api-configConfigMap volume mounts update within ~1 min but apps need restarts to reload. Use Reloader controller to auto-trigger rolling restarts on ConfigMap/Secret changes.