DEV Community

Cover image for Kubernetes Self-Healing Reconciliation Loop
Adi Polak
Adi Polak

Posted on

Kubernetes Self-Healing Reconciliation Loop

Reconcili WHAT ?!?!

Reconciliation - the action of making one view or belief compatible with another.

Or in a simpler way - maintaining desired state

The deployment desired state is the state we defined in our deployment YAML file. Not sure what it means? have time to spare? Read here for example and tutorial.

Kubernetes understand it and leverage the controllers to continually check the desired state specified by each resource against the actual state of the cluster.

Kubernetes later will do any necessary adjustments to keep them in sync. This process is called the reconciliation loop.
Trying to reconcile the actual state with the desired state, forever.

When you first create a Deployment, there is no Pod running, because this is the first time you are creating it. So K8s will start the required Pod immediately. If the Pod was ever to stop, Kubernetes(K8s) will start it again, as long as the Deployment exists.

With creating Deployment, K8d controllers know that the Pod must always be running. Hence, even if we delete the Pod ourselves, Kubernetes assumes we must probably made a mistake, and starts a new Pod to replace the deleted one.

Reconciliation loop is part of K8s self healing abilities. When something goes wrong, meaning the desired state and the actual state doesn't match, K8s will try to close the gap, forever.

Until death do them apart...

K8s will try forever until we either delete the deployment, or its infra fails.

💀 Done and want to fully shot down the Deployment?

Run this:

kubectl delete all --selector app={app name identifier goes here}
Enter fullscreen mode Exit fullscreen mode

💡 Want to learn more ?

Reconciliation loop is a concept that brought to us from the world of Electronic and system Engineering. If you are curious to know more about the algorithm and its pros and cons, read here about Edge and level triggering.
Another resource for learning K8s are the O'Reilly books, one of them is: Cloud Native DevOps with Kubernetes.

Thank you 🙏

You are welcome to follow me on Twitter, happy to take your questions, ideas, and suggestions on topics.

Top comments (0)