The challenge for the #KubeWeek

The challenge for the #KubeWeek

☸ What is Kubernetes?

  1. Kubernetes is an open-source Container Management tool that automates Container deployment, container scaling & load balancing.

  2. It schedules, runs, and manages isolated containers which are running on Virtual/Physical/Cloud Machines.

  3. All top Cloud Providers support Kubernetes.

☸ History

Google developed an internal system called 'borg' (later named as omega) to deploy and manage thousands of Google applications and services on their cluster.

In 2014, google introduced Kubernetes an open-source platform written in 'Golang' and later donated to CNCF.

☸ Kubernetes Installations tool

  1. Minikube

  2. Kubeadm

☸ Feature of Kubernetes

  • Orchestration

  • Autoscaling

  • Auto-Healing

  • Load Balancing

  • Platform Independent

  • Fault Tolerance

  • Rollback

  • Health Monitoring of containers

  • Batch Execution (one-time, sequential, parallel)

☸ Architecture of Kubernetes

Role of Master node

  1. Kubernetes designates one or more of these as masters and all others as workers.

  2. The master is now going to run a set of K8s processes. These processes will ensure the smooth functioning of the cluster. These processes are called "Control Plane".

  3. Can be a Multi-master for high availability.

  4. The master runs the control plane to run the cluster smoothly.

Component of Control Plane (Master node)

1.Kube-API server

2.ETCD Cluster

3.Kube-Scheduler

4.Kube-Controller Manager

✏️ Kube-API server (For all communication)

This API server interacts directly with the user (i.e. we apply .yml or json manifest to kube-Apiserver)

✏️ ETCD Cluster

Stores metadata and status of Cluster.

ETCD is a consistent and high-available store (Key-value store)

Source of touch for cluster state (info about the state of the cluster)

Etcd has the following feature

a. Fully replicated: the entire state is available on every node in the cluster.

b. Secure: implements automatic TLS with optional client-certificate authentication.

c. Fast: benchmarked at 10,000 writes per second

✏️ Kube-Scheduler

Responsible for scheduling the pods on the nodes.

It just decides which pod to place on which node band on the CPU, RAM, and resources on the Node.

Kubelet places the nodes after the scheduler decides.

The right container/pod is sent to the right snip/node.

✏️ Kube-Controller Manager

Continuously monitor various components of the cluster and works toward managing/restoring to the desired state.

* Node Controller

Communicates with kube Apiserver and manages nodes. [Every 5 seconds]

Checks again for 40 seconds then mark as "unreachable"

After 5 minutes it replaces

*Replication Controller

Responsible for monitoring the status of the replica set.

Ensures that desired no. of Pods are available at the required time.

✏️ Kubelet

The agent running on the node.

Listens to Kubernetes master (eg:- Pod creation request)

Use Port 10255

Send success/fail reports to master.

✏️ Container Engine (Docker)

Works with Kubelet

Pulling images

Start/Stop Containers

Exposing containers on ports specified in the manifest

✏️ Kube-Proxy

Assign IP to each Pod.

It is required to assign IP addresses to pods(dynamic).

Kube-Proxy runs on each node & this makes sure that each pod gets its own unique IP address.

These 3 components collectively consist of "node".

*POD

  1. The smallest unit in Kubernetes.

  2. POD is a group of one or more containers that are deployed together on the same host.

  3. A Cluster is a group of nodes.

  4. A Cluster has at least one worker node and a master node.

  5. In Kubernetes, the control unit is the pod, not the containers.

  6. Consist of one or more tightly coupled containers.

  7. POD runs on a node, which is controlled by the master.

  8. Kubernetes only knows about PODS (does not know about individuals container).

  9. Cannot start containers without a POD.

  10. One Pod usually contains one container.

*Replica sets

To prevent users from losing access to the app, the replication controller gives high availabilities.

Help in load balancing and scaling.

*Deployment

Pods deploy single instances of an application.

Deployment allows updating the pod's infrastructure with Replicas, Rolling updates, etc.

*Services

Helps us connect our applications with other applications/databases etc.

✏️ Kubectl

A command line tool used to communicate with a Kubernetes cluster's control plane.

Kubectl apply.

Creates the live object for the configuration

☸ Kubernetes Installations and Configurations

1.Login into AWS account-> Launch 2 Instances--> Ubuntu 22.04 LTS (t2.medium) Master must have 2 VCPUs and 4GB RAM and for Worker Node instance type (t2.micro).

2.Commands Common for Master and Worker Node

sudo apt-get update

3.Now install docker on all 2 instances

sudo apt install docker.io -y

4.To Check, whether docker is installed or not

docker --version
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

5.Install kubeadm on both machines

Kubeadm is a tool for deploying a Kubernetes cluster. You can use the following commands to install kubeadm, kubelet, and kubectl:

 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

6.The next step is to configure the master node

 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

 kubeadm token create --print-join-command

7.The last step is to configure the Worker Node

Firstly add an inbound rule in Master Node add Port No 6443

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

8.Verify the Cluster Finally, run the following command on the master node to verify that the cluster is up and running

kubectl get nodes

for the more detailed Explanation of the Kubernetes Refer the blog from https://spacelift.io/blog/kubernetes-cheat-sheet thank you @ https://www.linkedin.com/in/mariusz-micha%C5%82owski/