Overview of Kubernetes with Architecture Explained!!

What is Kubernetes?

Kubernetes is a open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. The name Kubernetes originates from Greek, meaning helmsman or pilot. Kubernetes was developed by google in go-lang and open-sourced the Kubernetes project in 2014.

Why Do we need Kubernetes?

Containers are a good way to bundle and run applications. Kubernetes manages the containers that run the applications and ensure that there is no downtime.

Benefits of Kubernetes?

Kubernetes provides with a framework to run distributed systems resiliently. It takes care of scaling and failover for application, provides deployment patterns, and more.

It does the following:

  • Service discovery and load balancing Kubernetes can expose a container using the DNS name or using their own IP address. If traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic so that the deployment is stable.
  • Storage orchestration Kubernetes allows to automatically mount a storage system, such as local storages, public cloud providers, and more.
  • Automated rollouts and rollbacks We can describe the desired state for deployed containers using Kubernetes, and it can change the actual state to the desired state at a controlled rate.
  • Automatic bin packing We can provide Kubernetes with a cluster of nodes that it can use to run containerized tasks. We can tell Kubernetes how much CPU and memory (RAM) each container needs. Kubernetes can fit containers onto your nodes to make the best use of your resources.
  • Self-healing Kubernetes restarts containers that fail, replaces containers, kills containers that don’t respond to user-defined health check, and doesn’t advertise them to clients until they are ready to serve.
  • Secret and configuration management Kubernetes lets to store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys. We can deploy and update secrets and application configuration without rebuilding container images, and without exposing secrets in stack configuration.

How Kubernetes works aka Kubernetes architecture with image

Kubernetes follows a client-server architecture. The master server consists of various components including a kube-apiserver, an etcd storage, a kube-controller-manager, a kube-scheduler. Node components include kubelet and kube-proxy on top of Docker.

Below are the main components found on the master node:

etcd cluster – a simple, distributed key value storage which is used to store the Kubernetes cluster data (such as number of pods, their state, namespace, etc), API objects and service discovery details. It is only accessible from the API server for security reasons. etcd enables notifications to the cluster about configuration changes with the help of watchers.

kube-apiserver – Kubernetes API server is the central management entity that receives all REST requests for modifications (to pods, services, replication sets/controllers and others), serving as frontend to the cluster. Also, this is the only component that communicates with the etcd cluster, making sure data is stored in etcd and is in agreement with the service details of the deployed pods.

kube-controller-manager – runs a number of distinct controller processes in the background to regulate the shared state of the cluster and perform routine tasks. When a change in a service configuration occurs, the controller spots the change and starts working towards the new desired state.

kube-scheduler – helps schedule the pods on the various nodes based on resource utilization. It reads the service’s operational requirements and schedules it on the best fit node.

Below are the main components found on a (worker) node:

kubelet – the main service on a node, regularly taking in new or modified pod specifications and ensuring that pods and their containers are healthy and running in the desired state. This component also reports to the master on the health of the host where it is running.

kube-proxy – a proxy service that runs on each worker node to deal with individual host subnetting and expose services to the external world. It performs request forwarding to the correct pods/containers across the various isolated networks in a cluster.

What is POD?

A pod encapsulates one or more applications. Pods also provide environmental dependencies, including persistent storage volumes and configuration data needed to run the container within the pod. If a pod fails, Kubernetes can automatically create a new replica of that pod to continue operations.