The purpose of kubernetes is to host your application in the form of containers in an automated fashion so that we can easily deploy as many instances as our application require and easily enable communication between different services within our application .
The Kubernetes cluster contains a set of nodes which may be physical or virtual, on-premises or on the cloud, that host applications in the form of containers.
We can take the example of two ships for better understanding, one ship which does the actual work of carrying all the containers(worker node) and another ship which monitors and manage the first ship(control node).
In the first ship, there are workers that are responsible for actually loading the containers in the ship.
Also, there are control that are responsible to keep track of containers, monitor, and store information about the ship, manage the whole loading process of the ship, etc.
Master Node
The master nodes are the control in Kubernetes, responsible for storing information regarding the different nodes, which container to monitor, etc.
The master node does all of this using set of components known as the control plain component.
Types of components in master node :
- etcd :
There are many containers being loaded & unloaded on a daily basis on ship. So we need to maintain information about what containers are loaded on which ship and what time is it loaded. All of these things are stored in a key-value store known as etcd.
Etcd is a database that stores the information in key-value format. Kubernetes uses etcd to store all of its data, its configuration data, its state, and its metadata.
- Scheduler
When the ship arrives at the hub, there is a crane that is used to load the containers. The cranes identifies what containers to load on which ship, how many containers are already on ship and where the ship is going, the type of container the ship is allowed to carry, etc.
These cranes are the scheduler(kube-scheduler) in the Kubernetes cluster.
The scheduler determines which nodes are correct placements for each Pod in a scheduling queue . The scheduler then ranks each node and binds the Pod to a suitable Node.
- Controllers
In hub, there are different offices to perform special task for each department. For example, the operation team takes care of ship traffic control, damages in routes of ship, etc. Some other department is responsible for managing the containers on the ship whether they are damanged or destroyed making sure to made the new container immediately available .
Similarly there are controllers in kubernetes to take care of different areas.
a. Node controllers
--> Responsible for onboarding new nodes when nodes become unavailable or destroyed .
b. Replication controllers
--> Responsible for ensuring the desired number of containers to be running all times .
So till now we have seen that there are different offices and departments for different tasks but how do each office reach out to other office and who manages all of them at higher level ?
Kube-API Server :
The kube-api server is the key management component in kubernetes for this . It is responsible for orchestrating all the operations within the cluster. It exposes the Kubernetes API to perform management operations on the cluster as well as controllers to monitor the state of cluster and make necessary changes as required.
Now, we know our applications in the form of containers and containers exist everywhere in Kubernetes. So we need the engine to run those containers known as container runtime environment.
For this, we require docker . Kubernetes also support other container runtime i.e containerD or rocket.
Now back to ships , we know there is always a captain on the ship that drives it. Here kubelet is captain in the ship.
Worker Node
Kubelet
A kubelete is an agent that run on each node in cluster . It listens to the instructions from the kube-api server and then destroys or deploys the containers on the nodes when required.
The kube-api server periodically fetches the status reports of state of nodes and containers on them from the kubelet. Kubelet act as captain on the ship that manage the containers on the ship
But the application running on worker node needs to be able communicate with each other. For example web server may be running on one of the container on one node and database server is running on another container on another node. But how would they communicate with each other ?
Kube-proxy
The communication between worker nodes are enabled by another component that runs on worker node known as kube-proxy service.It enables the rules so that each container on worker node can communicate with each other .
So this was all about Understanding Kubernetes Architecture in the form of example of a ship where we have containers on them.
Hope you have enjoyed the simple way of understanding the concepts .
Thanks each and every reader of this post.
- Siraj Khan (devops enthusiast)