How Kubernetes works on reconciler pattern.

Kubernetes is very hot right now in the industry and everyone wants to learn and use it. In this article, we will read about how Kubernetes works on a reconciler pattern.

We have previously talked about the reconciler pattern and how you can use it. You can have a look at the writeup in the below link.

Reconciler pattern in the simple word checks the difference between the desired state and the current state and if there is a difference, it tries to take action to make the current state to the desired state. If you want to read more about it you can read the above article or link here.

How Kubernetes works on reconciler pattern.

Kubernetes follows the same patterns. If you start looking at the code. Kubernetes has two major tasks it does. It watches for the resources in etcd for any change. And if there is any change if tries to reconcile and bring the state to that particular defined state in etcd. Look at the below diagram

How Kubernetes works on a reconciler pattern

Here you can see no other component other than API server interact with etcd. All of these components run in parallel keep a watch on resources in etcd via api server and whenever there is a change in any resource they take steps to match the current state to the required state. You can run all these controller managers, kubelet, scheduler and API server separately. You can run their binary and pass them config of API server and for API-server pass the config of etcd.

Its not just the Kubernetes code base but also the pattern the operator-sdk and kube-builder use to create operators for Kubernetes.

It’s a very simple but powerful idea to calculate the difference and apply the changes. Since all the workers are doing their tasks and no one is pushing others to do the task, it is easy for them to scale. Since they are work asynchronously, this adds good scalability to the system. If the system is synchronous it may have to wait for one of the downstream to complete the task it can cause scalability issues. But in asynchronous systems chances of happening this is very small as compared to synchronous counterparts.

Also, they can keep doing their tasks independently of the other components it and together and gives the experience that you get out of Kubernetes.

This was very basic of how Kubernetes works on a reconciler pattern. If you like the article please share.

Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.