Before we enter into the practicals, we will finish the theory first (i.e.) understanding the terms and components involved.
Let us start with the nodes.
A node is a machine, physical or virtual, on which the Kubernetes is installed. A node is a worker machine and this is where the containers will be launched by Kubernetes. It is also known as minions.
Obviously, our application goes down and we don't want that to happen. That is why we have clusters.
A cluster is a set of nodes grouped together. Hence, even if one node fails, you have your application still accessible from other nodes. Also, having multiple nodes helps in sharing the load.
We have nodes and clusters, but,
- who will be the orchestrator to manage these clusters and nodes?
- Where is the information about the members of the clusters stored?
- How are the nodes monitored?
- When a node fails, how do you move the workload of the failed node to another worker node?
This is where the master or the orchestrator comes into the picture. The master is another node with Kubernetes installed in it, and is configured as Master.
The master watches over the nodes in the cluster and is responsible for the actual orchestration of containers on the worker nodes.
When Kubernetes is installed in a system, the following components are installed along with Kubernetes.
- API Server: The API server acts as the front-end for Kubernetes. The CLI, users, management devices all talk to the API server to interact with the Kubernetes cluster.
- ETCD Key store: ETCD is a distributed reliable key-value store used by Kubernetes to store all data required to manage the key-value store. When you have multiple nodes and multiple masters in your cluster, ETCD stores all the information on all nodes in the cluster in a distributed manner(sync). ETCD is responsible for implementing locks within the cluster to ensure that there are no conflicts between the masters .
- Scheduler: It is responsible for distributing work or containers across multiple nodes. It looks for newly created containers and assign them to nodes.
- Controllers: They are the brains behind an orchestration and are responsible for identifying and responding when nodes, containers, or endpoints(Services) goes down. The controllers make the decisions to bring up new containers in such cases.
- Container Runtime: It is the underlying software used to run the containers. We use docker for container runtime.
- Kubelet: Kubelet is the agent that runs on each node in the cluster. The agent is responsible for making sure that the containers are running on the nodes as expected.
Now we saw the different components involved in kubernetes. But what makes one a master and others a node.
Master is the node, which has the kube-api server and that's what makes it a master. It also has the ETCD, controller and scheduler components.
Worker node or simply node is the one which has the container runtime and the Kubelet.