DEV Community

BPB Online
BPB Online

Posted on

How does Kubernetes work?

Kubernetes is an open-source container management system used in large-scale enterprises in several dynamic industries to perform a mission-critical task or an orchestration task.

Some of its capabilities include the following:

  • It manages the containers inside the cluster.
  • It deploys applications to which it provides tools.
  • It scales the applications as per requirement.
  • It manages the existing containerized application changes.
  • It optimizes the use of the underlying hardware complexity beneath our container.
  • It enables an application component to restart and move across multiple systems as per need.

What are the Advantages of Kubernetes?

The following are the advantages of Kubernetes:
Portable and Open-Source:
Kubernetes can run the containers on one or more public cloud environments, virtual machines, or bare metal, which means it can be deployed on any infrastructure. Moreover, Kubernetes is compatible across multiple platforms, making a multi-cloud strategy a highly flexible and usable component.

Workload Scalability:
Kubernetes course offers the following useful features for scaling purposes:

  • Horizontal Infrastructure Scaling: Operates on the individual server level to implement horizontal scaling. New servers can be added or removed easily.

  • Auto-Scaling: We can alter the number of containers running, based on the usage of CPU resources or other application metrics.

  • Manual Scaling: The number of running containers through a command or the interface can be manually scaled.

  • Replication Controller: The replication controller makes sure that the cluster has a specified number of equivalent pods in a running condition. If there are too many pods, the replication controller can remove the extra pods or vice-versa.

High Availability:
Kubernetes can handle the availability of both the applications and the infrastructure. It tackles the following:

  • Health Checks: The application doesn’t fail by constantly checking the health of modes and containers. Kubernetes offers self-healing and auto replacement if a pod crashes due to an error.

  • Traffic Routing and Load Balancing: Kubernetes’ load balancer distributes the load across multiple loads, enabling us to balance the resources quickly during incidental traffic or batch processing.

Designed for Deployment:
Containerization has the ability to speed up the process of building, testing, and releasing the software, and the useful features include the following:

  • Automated Rollouts and Rollbacks: It can handle the new version and update our app without any downtime, while we monitor the health during the roll-out process. If any failure occurs during the process, it can automatically roll back to the previous version.

  • Canary Deployments: So, the production of the new deployment and the previous version can be tested in parallel, that is, before scaling up the new deployment and parallelly scaling down the previous deployment.

  • Programming Language and Framework Support: Most of the programming languages and frameworks like Java, Python, and so on, are supported by Kubernetes. If an application has the ability to run in a container, it can run in Kubernetes as well.

Kubernetes and Stateful Containers:
Kubernetes’ Stateful Sets provides resources like volumes, stable network ids, and ordinal indexes from 0 to N, and so on, to deal with the stateful containers. Volume is one such key feature that enables us to run the stateful application. The two main types of volume supported are as follows:

  • Ephermal Storage Volume: Ephermal data storage is different from Docker. In Kubernetes, the volume is taken into account in any containers that run within the pod, and the data is stored across the container. But, if the pods get killed, the volume is automatically removed.

  • Persistent Storage: The data remains for a lifetime. So, when the pod dies or is moved to another node, that data will still remain until it is deleted by the user. Hence, the data is stored remotely.

How do Kubernetes work?
A cluster is the foundation of Google Kubernetes Engine (GKE); the Kubernetes objects that represent your containerized applications all run on top of a cluster. In GKE, a cluster consists of at least one control plane and multiple worker machines, called nodes. These control planes and node machines run the Kubernetes cluster orchestration system.

Master:
The master is the controlling element of the cluster. The master has the following three parts:

  • API Server: The application that serves Kubernetes’ functionality through a RESTful interface and stores the state of the cluster.

  • Scheduler: The scheduler watches the API server for the new Pod requests. It communicates with the Nodes to create the new pods and assign work to the nodes while allocating the resources or imposing constraints.

  • Controller Manager: The component on the master runs the controllers. It includes the Node controller, Endpoint Controller, Namespace Controller, and so on.

Slave (Nodes): These machines perform the requested, assigned tasks. The Kubernetes master controls them. There are the following four components inside the Nodes:

  • Pod: All containers will run in a pod. Pods abstract the network and storage away from the underlying containers. Your app will run here.

  • Kubelet: The Kubectl registers the nodes with the cluster, watches for work assignments from the scheduler, instantiates new Pods, and reports back to the master.

  • Container Engine: It is responsible for managing the containers, image pulling, stopping the container, starting the container, destroying the container, and so on.

  • Kube Proxy: It is responsible for forwarding the app user requests to the right pod.

Why do we need Kubernetes?
We need Kubernetes to manage the containers when we run our production-grade environments using a pattern of microservice with many containers. We need to track features such as health check, version control, scaling, and rollback mechanism among other things. It can be quite challenging and frustrating to make sure that all of these things are running alright.

Kubernetes gives us the orchestration and management capabilities required to deploy the containers at scale. Building the application services with the Kubernetes orchestration allows us to span multiple containers and timely schedule those containers across a cluster, scale those containers when it’s not in use, and manage the health of those containers from time to time. In a nutshell, Kubernetes is more like a Master manager that has many subordinates (containers). What a manager does is maintain what the subordinates need to do.

Hope this was helpful.

Discussion (0)