Skip to main content
In modern Kubernetes environments, troubleshooting can become cumbersome when ConfigMap or Secret updates don’t automatically trigger pod restarts. This guide introduces Reloader, a Kubernetes controller designed to automate rolling upgrades of your Deployments, DaemonSets, or StatefulSets whenever there’s a change in ConfigMap or Secret objects.
The image shows a GitHub repository page for "stakater/Reloader," displaying the file structure, recent commits, and a brief description of the project. The repository is a Kubernetes controller for managing ConfigMap and Secrets changes.
Reloader continuously monitors for modifications in your ConfigMaps and Secrets. When a change is detected, it triggers a rolling upgrade, ensuring that your Kubernetes resources are immediately redeployed without any manual intervention.
The image shows a webpage from Stakater discussing a tool for Kubernetes that performs rolling upgrades when changes occur in ConfigMap or Secret. It outlines the problem, solution, and offers an enterprise version with additional support features.

How Reloader Works

To leverage Reloader in your Kubernetes cluster, add the following annotation to your Deployment, StatefulSet, or any applicable resource. This annotation instructs Reloader to monitor the associated ConfigMap(s) and Secret(s) for changes and automatically restart the resource when necessary.
You can configure Reloader to monitor all associated ConfigMaps and Secrets or restrict its scope to specific ones. In this guide, we use the generic annotation for simplicity.

Deploying Reloader

Deploy the Reloader controller to your Kubernetes cluster using the vanilla manifest. While Helm is available for more complex deployments, the default manifest installation is straightforward:
Once deployed (by default in the default namespace), verify its status using:
You should see an output similar to:
Ensure your cluster has the necessary permissions for Reloader to manage your deployments.

Integrating Reloader with Your Application

Consider a scenario where a web application relies on a ConfigMap named “web-message”. This ConfigMap provides a greeting message for the application. Use the following command to deploy the Reloader components:
A sample output might be:
To inspect the pods and ConfigMaps in the production namespace, run:
For example, if your web application is configured with a ConfigMap value of “Hello, World”, verify it by executing:
If you see:
then your application is using the expected configuration.

Adding the Reloader Annotation

To enable Reloader for your application, update your deployment definition with the Reloader annotation. Below is an example of a Deployment configuration with the necessary annotation:
After applying this update, Reloader will automatically initiate a restart of the deployment whenever there’s a change to any associated ConfigMaps or Secrets. Apply the updated configuration by running:
Then, inspect your production pods:
You can also review your deployment details with:

Updating a ConfigMap and Observing Reloader in Action

To demonstrate Reloader’s functionality, update the ConfigMap to change the greeting message. Use the following updated ConfigMap configuration:
After applying the updated ConfigMap, observe that the Deployment is immediately restarted—the old pods are terminated and new ones are created. Confirm the current state with:
Then, connect to one of the new pods and check the environment variable:
A successful update should display:
This demonstration highlights how Reloader minimizes manual interventions, saving time and ensuring your application configuration changes are applied efficiently.

Conclusion

Reloader streamlines the process of handling ConfigMap and Secret updates by automating the restart of Kubernetes resources. This automation not only simplifies troubleshooting but also reduces potential downtime in your applications. Use Reloader to enhance your Kubernetes deployment workflows and ensure smooth and continuous integration of configuration changes. Happy deploying, and enjoy the benefits of automated rolling upgrades!

Further Reading and Resources

For more information on Kubernetes best practices and troubleshooting, check out additional guides on Kubernetes Basics.

Watch Video