Reloader
Automatically restart pods when their ConfigMaps or Secrets change.
Time: ~10 minutes Difficulty: Beginner
What You Will Learn
Section titled “What You Will Learn”- How Stakater Reloader watches ConfigMaps and Secrets
- Three reload modes: auto, specific, and no-reload
- Why pods do not pick up config changes without a restart
- How to trigger rolling restarts automatically on config updates
- When to use each annotation mode
Prerequisites
Section titled “Prerequisites”Install Stakater Reloader using Helm:
helm repo add stakater https://stakater.github.io/stakater-chartshelm repo updatehelm install reloader stakater/reloader -n reloader --create-namespaceWait for Reloader to be ready:
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=reloader -n reloader --timeout=60sDeploy
Section titled “Deploy”Navigate to the demo directory:
cd demos/reloaderDeploy the resources:
kubectl apply -f manifests/namespace.yamlkubectl apply -f manifests/configmap.yamlkubectl apply -f manifests/secret.yamlkubectl apply -f manifests/deployment-auto.yamlkubectl apply -f manifests/deployment-specific.yamlkubectl apply -f manifests/deployment-ignored.yamlkubectl apply -f manifests/service.yamlWait for all pods to be ready:
kubectl wait --for=condition=ready pod -l app -n reloader-demo --timeout=60sVerify
Section titled “Verify”Check that all three deployments are running:
kubectl get deployments -n reloader-demokubectl get pods -n reloader-demoYou should see three deployments, each with 2 replicas:
web-auto(watches all referenced ConfigMaps and Secrets)web-specific(watches only the app-config ConfigMap)web-ignored(no Reloader annotation, will not auto-restart)
Update the ConfigMap and watch the magic happen
Section titled “Update the ConfigMap and watch the magic happen”Open a watch window to see pod restarts in real time:
kubectl get pods -n reloader-demo -wIn another terminal, update the ConfigMap:
kubectl patch configmap app-config -n reloader-demo \ --type=merge -p '{"data":{"APP_MESSAGE":"Hello from v2"}}'You will see:
web-autopods: rolling restart triggered (new pods created, old ones terminated)web-specificpods: rolling restart triggered (watches app-config)web-ignoredpods: NO restart (still running with old config)
Verify the restart happened
Section titled “Verify the restart happened”Check pod ages after the update:
kubectl get pods -n reloader-demo -o wideThe web-auto and web-specific pods will have a recent creation time, while web-ignored pods remain old.
Verify the new config is loaded:
kubectl exec deploy/web-auto -n reloader-demo -- env | grep APP_MESSAGEkubectl exec deploy/web-specific -n reloader-demo -- env | grep APP_MESSAGEkubectl exec deploy/web-ignored -n reloader-demo -- env | grep APP_MESSAGEThe first two will show “Hello from v2”, while web-ignored still shows “Hello from v1”.
What is Happening
Section titled “What is Happening”manifests/ namespace.yaml # reloader-demo namespace configmap.yaml # ConfigMap with APP_MESSAGE and index.html secret.yaml # Secret with DB_PASSWORD and API_KEY deployment-auto.yaml # Watches ALL referenced ConfigMaps and Secrets deployment-specific.yaml # Watches only the app-config ConfigMap deployment-ignored.yaml # No Reloader annotation (control group) service.yaml # ClusterIP services for each deploymentStakater Reloader solves the classic Kubernetes problem: updating a ConfigMap or Secret does not restart pods automatically. Pods that inject config as environment variables never see updates. Pods that mount config as volumes can see updates after a kubelet sync delay (10-60 seconds), but only if the volume is mounted as a directory, not a subPath.
Reloader monitors ConfigMaps and Secrets. When a change is detected, it triggers a rolling restart of the Deployment, StatefulSet, or DaemonSet. The restart is done by updating a pod template annotation, which Kubernetes treats as a spec change.
Three annotation modes:
| Annotation | Watches | Use Case |
|---|---|---|
reloader.stakater.com/auto: "true" | All referenced ConfigMaps and Secrets | Simple setup, watches everything |
configmap.reloader.stakater.com/reload: "name" | Specific ConfigMap(s) | Fine-grained control, only restart for certain configs |
secret.reloader.stakater.com/reload: "name" | Specific Secret(s) | Fine-grained control for Secrets |
| (no annotation) | Nothing | Pods keep running with old config until manual restart |
You can specify multiple resources in the specific mode by separating them with commas: configmap.reloader.stakater.com/reload: "config1,config2".
Experiment
Section titled “Experiment”-
Update the Secret and observe that only
web-autorestarts (sinceweb-specificonly watches ConfigMaps):Terminal window kubectl patch secret app-secret -n reloader-demo \--type=merge -p '{"stringData":{"DB_PASSWORD":"super-secret-v2"}}'kubectl get pods -n reloader-demo -w -
Add a Secret-specific annotation to
web-specificand update the Secret again:Terminal window kubectl patch deployment web-specific -n reloader-demo \--type=merge -p '{"metadata":{"annotations":{"secret.reloader.stakater.com/reload":"app-secret"}}}'kubectl patch secret app-secret -n reloader-demo \--type=merge -p '{"stringData":{"DB_PASSWORD":"super-secret-v3"}}' -
Add the auto annotation to
web-ignoredand verify it now restarts on config changes:Terminal window kubectl patch deployment web-ignored -n reloader-demo \--type=merge -p '{"metadata":{"annotations":{"reloader.stakater.com/auto":"true"}}}'kubectl patch configmap app-config -n reloader-demo \--type=merge -p '{"data":{"APP_MESSAGE":"Hello from v3"}}' -
Check Reloader logs to see it detecting and processing config changes:
Terminal window kubectl logs -f deployment/reloader-reloader -n reloader -
Try the search and match mode (advanced): add
reloader.stakater.com/search: "true"to a Deployment andreloader.stakater.com/match: "true"to a ConfigMap. Reloader will watch all ConfigMaps with the match annotation.
Cleanup
Section titled “Cleanup”Delete the demo namespace:
kubectl delete namespace reloader-demoOptionally, uninstall Reloader:
helm uninstall reloader -n reloaderkubectl delete namespace reloaderFurther Reading
Section titled “Further Reading”See docs/deep-dive.md for a detailed explanation of how Reloader detects changes, the rolling restart mechanism, performance considerations, and advanced annotation modes.
Next Step
Section titled “Next Step”Move on to Knative Serving to learn about serverless workloads on Kubernetes with scale-to-zero and revision-based traffic splitting.