Kwatcher is a Kubernetes operator that:
- Automatically creates a ConfigMap from data fetched from an external URL using a secured
Secret, - Periodically polls the URL (based on
refreshInterval), - Updates the ConfigMap when the data changes,
- And automatically triggers pod redeployment via annotations in the related
Deployments.
Kwatcher is especially useful when your application relies on external configuration data that changes dynamically. It automates the entire flow:
- fetching external data,
- updating a Kubernetes
ConfigMap, - and redeploying affected pods.
- Dynamic configuration: feature flags, business rules, or third-party configs.
- Cross-cluster syncing: consuming external configuration from other environments or clusters.
- Auto-sync without CI/CD: no manual rollouts or pipeline triggers.
- Fast updates: reacts to data changes in near real-time (e.g., every 30s).
- 100% declarative (Kubernetes-native)
- Secured with
Secretintegration - Avoids unnecessary redeployments
- Ideal for config-sensitive microservices
- Define a
Kwatchercustom resource with:- An external URL,
- Port number,
- Polling interval (
refreshInterval), - A
Secretwith credentials.
⚠️ Important:
The referencedSecretmust exist before theKwatcheris created.
Otherwise, the custom resource will failed.
-
Automatic ConfigMap creation
When a
Kwatcheris created, the operator generates aConfigMapwith the same name (e.g.,example-kwatcher) and stores the fetched content in it. It is refreshed at the specified interval. -
Triggering pod redeployment
In your
Deployment, add annotations like:kwatcher.config/watched-configmaps: "example-kwatcher" kwatcher.config/update-policy: "explicit"
The operator will patch an additional annotation (
kwatcher.config/last-updated) on the pod template to trigger Kubernetes to roll out a new version.
apiVersion: core.kwatch.cloudcorner.org/v1beta1
kind: Kwatcher
metadata:
name: example-kwatcher
spec:
provider:
port: 443
url: "https://api.jsonbin.io/v3/b/67efdc378960c979a57e2d50"
config:
refreshInterval: 30
secret: "secret-1"🧾 How headers work
client-key: the actual API key to be used.key-type: the HTTP header name (e.g.Authorization,X-API-Key) in which the key must be sent.Example: if
key-typeisX-Access-Key, then the request will include:
apiVersion: v1
kind: Secret
metadata:
name: secret-1
type: Opaque
data:
client-key: <base64 encoded value>
key-type: <base64 encoded value> # "Authorization/X-API-Key/.."The
Secretmust already exist before applying theKwatcher.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 4
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
redeploy-check: "initial"
kwatcher.config/update-policy: "explicit"
kwatcher.config/watched-configmaps: "example-kwatcher"
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80+-----------------------------+
| Secret (credentials) |
| must exist BEFORE the |
| Kwatcher is created |
+-------------+---------------+
|
v
+-----------------------------+
| Custom Resource |
| kind: Kwatcher |
| (url + secret + interval) |
+-------------+---------------+
|
v
+-----------------------------+
| Periodic HTTP call |
| to external URL (e.g. 30s) |
+-------------+---------------+
|
v
+-----------------------------+
| ConfigMap (auto-created) |
| same name as the CR |
+-------------+---------------+
|
v
+-----------------------------+
| Deployment with annotations|
| - kwatcher.config/... |
| - watched-configmaps |
+-------------+---------------+
|
v
+-----------------------------+
| Operator patches annotation|
| -> triggers redeployment |
+-----------------------------+
To fully generate and deploy the operator using Helm, you can run the following command:
make allThis command performs the entire workflow:
- Generates Kubernetes manifests using
controller-gen(viamake manifests) - Builds the Docker image for the operator
- Pushes the image to your Docker registry
- Installs required tools:
kustomizeandhelmifyif missing - Generates a Helm chart from Kustomize output using
helmify - Updates the Helm chart with the correct Docker image and tag
- Packages the chart and updates the local Helm repo index
helm install kwatcher ./charts/kwatcher-operator-<version>.tgzReplace <version> with the appropriate chart version (e.g. 0.1.0).
To install the operator directly from GitHub Container Registry (GHCR), use the following command:
helm install kwatcher oci://ghcr.io/berg-it/kwatcher-operator --version 0.1.0This will install the Helm chart named kwatcher-operator from my public GHCR package.
- Support multiple URLs per
Kwatcher - Advanced update strategies (e.g. rolling, blue/green)
- Schema validation of external data
Contributions are welcome!
Feel free to open an issue or submit a pull request to improve the project.
Distributed under the MIT License.