Kubernetes architecture and cluster

Kubernetes architecture and cluster

What is Kubernetes?

Kubernetes is also known as 'k8s'. This word comes from the Greek language, which means a pilot or helmsman.
Kubernetes is an extensible, portable, and open-source platform designed by Google in 2014. It is mainly used to automate the deployment, scaling, and operations of the container-based applications across the cluster of nodes. It is also designed for managing the services of containerized apps using different methods which provide the scalability, predictability, and high availability.

It is actually an enhanced version of 'Borg' for managing the long-running processes and batch jobs. Nowadays, many cloud services offer a Kubernetes-based infrastructure on which it can be deployed as the platform-providing service. This technique or concept works with many container tools, like docker, and follows the client-server architecture.


Kubernetes Architecture

image as taken from javatpoint website

The architecture of Kubernetes actually follows the client-server architecture. It consists of the following two main components:

  1. Master Node (Control Plane)

  2. Slave/worker node

Master Node or Kubernetes Control Plane

The master node in a Kubernetes architecture is used to manage the states of a cluster. It is actually an entry point for all types of administrative tasks. In the Kubernetes cluster, more than one master node is present for checking the fault tolerance.

Following are the four different components which exist in the Master node or Kubernetes Control plane:

  1. API Server

  2. Scheduler

  3. Controller Manager

  4. ETCD

API Server

The Kubernetes API server receives the REST commands which are sent by the user. After receiving, it validates the REST requests, process, and then executes them. After the execution of REST commands, the resulting state of a cluster is saved in 'etcd' as a distributed key-value store.

Scheduler

The scheduler in a master node schedules the tasks to the worker nodes. And, for every worker node, it is used to store the resource usage information.
In other words, it is a process that is responsible for assigning pods to the available worker nodes.

Controller Manager

The Controller manager is also known as a controller. It is a daemon that executes in the non-terminating control loops. The controllers in a master node perform a task and manage the state of the cluster. In the Kubernetes, the controller manager executes the various types of controllers for handling the nodes, endpoints, etc.

ETCD

It is an open-source, simple, distributed key-value storage which is used to store the cluster data. It is a part of a master node which is written in a GO programming language.

Now, we have learned about the functioning and components of a master node; let's see what is the function of a slave/worker node and what are its components.

Worker/Slave node

The Worker node in a Kubernetes is also known as minions. A worker node is a physical machine that executes the applications using pods. It contains all the essential services which allow a user to assign the resources to the scheduled containers.

Following are the different components which are presents in the Worker or slave node:

Kubelet

This component is an agent service that executes on each worker node in a cluster. It ensures that the pods and their containers are running smoothly. Every kubelet in each worker node communicates with the master node. It also starts, stops, and maintains the containers which are organized into pods directly by the master node.

Kube-proxy

It is a proxy service of Kubernetes, which is executed simply on each worker node in the cluster. The main aim of this component is request forwarding. Each node interacts with the Kubernetes services through Kube-proxy.

Pods

A pod is a combination of one or more containers which logically execute together on nodes. One worker node can easily execute multiple pods.


How to make Kubernetes cluster

Step 1: make one instance with name master

with instance, type is t2.medium

Step 2: make another instance with name worker-server it can be instance type t2.micro

Step 3: connect this two instance through the SSH client

Step 4: Install docker in both master and worker server

sudo apt-get update 
sudo apt-get docker.io

Step 5: Run these commands in both master and worker server

sudo systemctl start docker
sudo systemctl enable docker

Step 6: Run these commands in both master and worker server

sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update -y

Step 7: Install Kudeadm, Kubectl and Kubelet in both master and worker server by running this commands

sudo apt install kudeadm=1.20.0-00 kubectl-1.20.0-00 kubelet=1.20.0-00 -y

Step 8: Run these commands in master server

sudo su

Step 9: Run these commands in master server

kubeadm init

Step 10: Run these commands in master server which is shown in image

export KUBECONFIG=/etc/kubernetes/admin.conf

Step 11: Run these commands in master server

kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

Step 12: Run these commands in master server

kubeadm token create --print-join-command

Step 13: Run these commands in worker server

sudo su

Step 14: Run these commands in worker server

kubeadm reset pre-flight checks

Step 15: Now in master server instance go and open port 6443

Step 16: Now paste the token created in master node in worker node like this

 kubeadm join 172.31.27.179:6443 --token 0hhy48.pgiotlry8wz02nsb     --discovery-token-ca-cert-hash sha256:35201b0e6d7463299052546856ec1217164b0bd79c60f6f7578d3fe077edaae1 --v=5

here you can see we have successfully connected

Step 17: Go to master server and run these commands

kubectl get nodes

here you can see we have connected worker node to master


Thank you for reading this blog and if any queries or if any corrections to be done in this blog please let me know.

contact us in Linkedin ,Twitter or email-id