Kubernetes Architecture and Components,
Kubernetes Installation and Configuration

Kubernetes Architecture and Components, Kubernetes Installation and Configuration

Day 1 of kubeweek challenge

What /Why is Kubernetes

Before discussing what I want to discuss why you need to learn kubernetes

Learning Kubernetes is essential for any DevOps professional. DevOps engineers are always in demand. The average Silicon Valley salary for a DevOps engineer is 20% higher than that of a software engineer.

DevOps engineers make an average of $140,000 to $200,000 annually. And one of the most in-demand skills is Kubernetes Deployment.

What is Kubernetes

Kubernetes, also known as K8s is an open-source system for automating the deployment, scaling, and management of containerized applications. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation.

The primary advantage of using Kubernetes in your environment, especially if you are optimizing app dev for the cloud, is that it gives you the platform to schedule and run containers on clusters of physical or virtual machines (VMs).

Features of Kubernetes

  • Auto-scaling

  • Lifecycle management

  • Declarative model.

  • Resilience and self-healing.

  • Persistent storage.

  • Load balancing.

  • Configuration management

  • Secret management

Kubernetes Architecture

The Kubernetes architecture is based on a master-slave model, where the master node manages the entire cluster while the worker nodes host the containers

  • Kubernetes control plane:- manages Kubernetes clusters and the workloads running on them. Include components like the API Server, Scheduler, and Controller Manager.

  • Kubernetes data plane:- machines that can run containerized workloads. Each node is managed by the kubelet, an agent that receives commands from the control plane.

  • Pods:- pods are the smallest unit provided by Kubernetes to manage containerized workloads. A pod typically includes several containers, which together form a functional unit or microservice.

  • Persistent storage:- local storage on Kubernetes nodes is ephemeral and is deleted when a pod shuts down. This can make it difficult to run stateful applications. Kubernetes provides the Persistent Volumes (PV) mechanism, allowing containerized applications to store data beyond the lifetime of a pod or node. This is part of an extensive series of guides about CI/CD.

Control Plane Components

  • Api server. As its name suggests the API server exposes the Kubernetes API, which is communications central. External communications via command line interface (CLI) or other user interfaces (UI) pass to the kube-apiserver, and all control planes to node communications also go through the API server.

  • etcd: The key-value store where all data relating to the cluster is stored. etcd is highly available and consistent since all access to etcd is through the API server. Information in etcd is generally formatted in human-readable YAML (which stands for the recursive “YAML Ain’t Markup Language”).

  • kube-scheduler: When a new Pod is created, this component assigns it to a node for execution based on resource requirements, policies, and ‘affinity’ specifications regarding geolocation and interference with other workloads.

  • kube-controller-manager: Although a Kubernetes cluster has several controller functions, they are all compiled into a single binary known as kube-controller-manager.

Worker node components

A worker node runs the containerized applications and continuously reports to the control plane's API-server about its health.

  1. Kubelet

    • It is an agent that runs on each node in the cluster.

    • It acts as a conduit between the API server and the node.

    • It makes sure that containers are running in a Pod and they are healthy.

    • It instantiates and executes Pods.

    • It watches API Server for work tasks.

    • It gets instructions from the master and reports back to Master.

  2. Kube-proxy

    • It is a networking component that plays a vital role in networking.

    • It manages IP translation and routing.

    • It is a network proxy that runs on each node in cluster.

    • It maintains network rules on nodes. These network rules allow network communication to Pods from inside or outside of the cluster.

    • It ensures each Pod gets a unique IP address.

    • It makes possible that all containers in a pod share a single IP.

    • It facilitates Kubernetes networking services and load-balancing across all pods in a service.

    • It deals with individual host sub-netting and ensures that the services are available to external parties.

  3. Container runtime

    • The container runtime is the software that is responsible for running containers (in Pods).

    • To run the containers, each worker node has a container runtime engine.

    • It pulls images from a container image registry and starts and stops containers.

Kubernetes Installation and Configuration

1-for the first step start with launching two instances one is master and other is worker

2- Install Docker on both master and worker instances

sudo apt-get update
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker

3- Install Kubeadm, Kubectl and Kubelet on both the master and worker node

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
sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y

4-Configure the master node by using these commands

sudo su
kubeadm init

#run the following as a regular user
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

#Alternatively, if you are the root user, you can run
export KUBECONFIG=/etc/kubernetes/admin.conf

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

kubeadm token create --print-join-command

Add port 6443 in inbound rules of master instances before connecting to worker node

5-Configure the worker node by using these commands

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

6-Check the connecting nodes by using this command on the master node

kubectl get nodes

Thankyou for reading!! many more in a queue

~Nikunj Kishore Tiwari

Great initiative by the #trainwithshubham community. Thank you Shubham Londhe for Guiding Us.