- Start your local manager (for example,
make runor your preferred controller run command). - Keep the logs visible so you can observe reconcile events while you perform the changes below.
- The WebApp resource is the blueprint. The controller should create the Deployment, Service, and ConfigMap from that spec.
- Deleting the Deployment demonstrates that the reconciler will recreate missing children based on the WebApp blueprint.
- Scaling the existing Deployment to zero simulates spec drift while the child resource still exists. In this controller implementation, the reconciler creates missing children but does not patch existing children to match the blueprint. Therefore the controller will not change the replica count back to three when the Deployment exists but has been modified.
- Now delete the modified (drifted) Deployment. Because it becomes a missing child again, the controller will recreate it from the WebApp spec with three replicas, restoring the application’s baseline.
This demonstrates the controller’s reconciliation boundary: it heals missing child resources by recreating them from the blueprint, but it does not repair in-place drift of existing child resources (for example, it will not scale an existing Deployment back to the blueprint’s replica count).
If you need automatic correction of in-place drift (for example, enforcing replica counts, updating image fields, or reconciling any spec drift), extend the reconciler logic to compare and patch existing children to match the desired blueprint spec rather than only creating missing children.
- Kubernetes Controllers and Operators
- Kubebuilder book — Writing a Controller
- Reconciliation Pattern (controller-runtime)