#KubeWeek Day1 - Understanding Kubernetes- Architecture and Components, Installation and Configuration

#KubeWeek Day1 - Understanding Kubernetes- Architecture and Components, Installation and Configuration

What is Kubernetes?

Kubernetes is an open-source container orchestration platform. developed by Google.

  • Helps in managing containerized applications in different deployment environments(virtual, Cloud, Physical, Hybrid).

  • Provide features of High Availability, High Performance, Disaster Recovery etc.,

Kubernetes architecture

Kubernetes follows Master node architecture.

Master Node(Control Plane)

The master node manages to schedule the pod, monitor,re-schedule / restart the pod, and join a new node.

The Master node has four components. Let's understand step by step.

  1. API server :

    whenever the user wants to deploy the application on a cluster in Kubernetes needs to interact with the API server using some client. the client can be UI like Kubernetes dashboard on command tool like Kubectl.

    So API server is like a cluster gateway from which it gets requests or queries about scheduling pods, deploying new applications, creating new services etc.,

    So it works like when a user requests to schedule a new pod API server checks the request, validates it and forwards it to the scheduler.

  2. Scheduler :

    After validating the request from the API server, the request will go to the scheduler. The scheduler will check which worker node has well-available resources to run this pod. it checks the resources like CPU and RAM which are needed to run the pod. In short, it decides on which node the new pod should be scheduled.

  3. Controller Manager:

    The controller manager detects state changes in the cluster like pod crashes or dies so it will request the scheduler to reschedule those pods.

  4. etcd:

    etcd is the cluster brain. It stores information about cluster data. When the pod get died or is scheduled all this information is saved or updated in etcd cluster in a key-value store format. It stores only cluster data, not application data.

Worker Node(Data Plane)

Three services must install on the worker node to work the Kubernetes cluster function properly. Each node has multiple pods on it. The services or components of the worker node are as below:

  1. Kubelet:

    Kubelet is responsible for managing the pods on the nodes. So if the pod is not running or dies kubelet will take care of it.

  2. KubeProxy:

    It takes care of the networking part in Kubernetes. It can be allocating ips to pod for communication.

  3. Container Runtime:

    It runs a container. It is responsible for running a container.

    First, need to install the container runtime service. we are using docker.

    then we need to install kubelet because it interacts with the container and node.

Kubernetes Installation and Configuration :

Let's see how to install Kubernetes on AWS. We need to make a cluster so we will use kubeadm installation.

We will create two EC2 instances one is a Master and another is a worker.

For Master Node we need the:

  • t2.medium.

  • 2-core CPU.

  • 4GB RAM.

For Worker Node we need the:

  • t2.micro

Launch Master Node Instance

  1. Select Ubuntu AMI.

  2. Select an instance type t2.medium.

  3. Select keypair.

  4. Allow HTTP/HTTPS ports.

Launch Worker Node Instance

  1. Select Ubuntu AMI.

  2. Select an instance type t2.micro.

  3. Select keypair.

  4. Allow HTTP/HTTPS ports.

Now we need to install docker on both the Master and Worker nodes.

sudo apt install docker.io -y

Now we have to start docker on both machines.

sudo systemctl start docker
sudo systemctl enable docker we need kubeadm

To set up Kubernetes we need kubeadm.

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

Update the package on both machines.

sudo apt update - Master node we need to install kubeadm

Now we will install kubeadm on Master Node and Worker Node.

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

Master node Configuration

sudo su
kubeadm init
mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

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

With the help of the below command any worker node that has a token can join the cluster.

kubeadm token create --print-join-command

It will generate like below:

kubeadm join <x.x.x.x Private ip>:<Port No.> --token --discovery-token-ca-cert-hash

We need to allow a port in the security group that is mentioned in the above tokens.

Now we will go to the worker node.

Worker Node Configuration

sudo su
kubeadm reset pre-flight checks
-----> Paste the Join command on worker node with `--v=5`

Now run the token command:

kubeadm join <x.x.x.x Private ip>:<Port No.> --token --discovery-token-ca-cert-hash --v=5

Now run the below command on Master Node

kubectl get nodes

Thank you.

Parimal Pradhan

Connect me on

LinkedIn: linkedin.com/in/parimal-pradhan-b62021168

Hashnod: https://parimalpradhan.hashnode.dev/

#Kubernetes #Devops #Kubeweek #kubeweekchallenge

Shubham Londhe

Did you find this article valuable?

Support Parimal Pradhan by becoming a sponsor. Any amount is appreciated!