Kubernetes

Kubernetes

Hello everyone! I am Goutham, and in this blog, I would like to explain what Kubernetes is and what problems it tries to solve its architecture and main components.

What is Kubernetes?

Kubernetes or simple K8's which means 8 letters between K and S is an open-source tool that is more than just container orchestration, which means managing several containers for an application that is deployed across several servers. Besides that, Kubernetes is also used for deploying, rolling out changes, scaling, and monitoring, making it easy to manage applications.

Kubernetes Components

Some of the important components in the Kubernetes World that I learned are

1 . Node and Pod

2. Service and Ingress

3. ConfigMap and Secrets

4. Deployment and Statefulset

Node and Pod

Node is just a server on which containers are deployed. Pod is an abstraction over a container, when a Pod is successfully created, it gets an IP address through which other Pods can communicate. Pods are emphimeral, which means they die easily and gets new IP when they are recreated. This makes it difficult to communicate with other pods. Hence, service has come.

Service and Ingress

Service is going to provide a permanent IP to a pod even when it is recreated, so communication among pods can happen with the previous IP address. The service accepts internal or external requests and forwards the request to the pods that are connected to the particular service. There might be replicas of pods, and the service can forward requests to one of the pods. So services can even act like load balancers.

Ingress is used to accept the request from outside the cluster and forward the request to service and service then forwards it to pods. There is a difference between external service and Ingress, external service accepts requests with IP address of the application but Ingress accepts with the domain name.

Deployment and Statefulset

Deployment is a template to create pods instead of creating a pod with command we write how many pods we want in a configuration file in YAML and we run that file this is called deployment.

We create deployment which creates pods and container runs inside a pod and application runs inside a container.

Statefulset is also a template to create pods but replicas created by statefulset is considered as different for example if we want to create database pods we have to choose statefulset as it ensures uniqueness among replicas but deployment doesn't.

Deplyment

Deployment

Statefulset

StatefulSet

ConfigMap and Secrets

Both are configuration files in YAML and keys in these files are used as environment variables while creating deployment files. Secrets contains usernames and passwords in base64 encoded ConfigMap contains some urls , names etc which we don't want to put in deployment files.

These are the components I learned in Kubernetes and I feel as important.

Now let's learn about Kubernetes Architecture.

Kubernetes Architecture

Cluster is a group of many nodes and Pods.

There are mainly 2 Nodes in Kubernetes

  1. MasterNode / Control Plane

  2. Worker Node

Containers of a application are deployed on worker nodes and most of the job was done by worker nodes and master node is used to manange all the containers across all the worker nodes.

There are some processes which are specific to MasterNode and WorkerNode.

Worker Node Processes

  1. Container Runtime

  2. Kubelet

  3. KubeProxy

Every Worker Node has these 3 processes installed through container runtime containers run inside a pod.

Kubelet can communicate with node and container. Kubelet starts pod with container inside.

KubeProxy provides intelligence to service, instead of randomly forwarding request that service receives to any other pods that the service was attached to. It forwards to the node from which it has received request ,to reduce network overheads.

Master Node Processes

1. API Server

2. Scheduler

3. Controller Manager

4. etcd

Master Node Processes are used to interact with workernodes cluster

API Server is an entry point to the Kubernetes cluster.

The scheduler decides on which worker node a new pod has to be scheduled, and kubectl on that worker node creates a new pod.

ControllerManager detects state changes in the cluster, and when any pod dies, it informs the scheduler, which then does its job.

etcd is called the brain of the cluster; it stores cluster-related data as a key-value pair, which means resources that node has used, the health of the cluster, and any pods that have died. All these are stored in etcd, and the etcd controller knows about pods, and the scheduler knows where to place a pod.

etcd doesn't store application related data.

I think I have everything that I have learned . I am beginner to DevOps and If you find any mistakes please let me know.

Thanks for reading my blog have a great day.