DEV Community

Cover image for Understanding Kubernetes: Its Significance and Benefits
7h3-3mp7y-m4n
7h3-3mp7y-m4n

Posted on

Understanding Kubernetes: Its Significance and Benefits

What is Kubernetes?

Kubernetes is now in everyone's minds, whenever we hear containers Microservices Kubernetes always shines in our brain. But what is Kubernetes? And why do we need it?

Kubernetes ☸️

Apart from being a giant ship wheel, Kubernetes is a wonderful orchestrator framework. It is generally used to manage applications that are made on top of containers- physical machines, virtual machines, and hybrid environments.

According to the website of k8s, Kubernetes is :

“A portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation”

What does it actually ?

Can it help me to cook lobster? Can I use it as the steering for my car? Can it help me with my math homework? No, but we can do pretty amazing things with it so let's roll back the time and understand it from the stone age.

Going back in time

Stone age man carving his computer
Traditional deployment era:

Traditional deployment image

Early on, organizations deployed applications on physical servers without the ability to clearly define resource boundaries for individual applications. This lack of resource delineation led to challenges in resource allocation. For instance, when multiple applications share a physical server, one application could monopolize most resources, adversely affecting the performance of other applications. While one solution was to run each application on a separate physical server, this approach proved inefficient and costly due to underutilized resources and the maintenance overhead associated with numerous physical servers.

Virtualized deployment era:

Virtualized deployment

As a remedy, virtualization emerged as a solution. It enables the concurrent operation of multiple Virtual Machines (VMs) on a single CPU of a physical server. Virtualization ensures the segregation of applications within individual VMs, enhancing security by restricting access to one application's information by others.

This approach optimizes resource utilization on a physical server, facilitating improved scalability. It streamlines the addition or updating of applications, reduces hardware expenses, and more. Virtualization enables the presentation of a pool of physical resources as a cluster of disposable virtual machines.

Each VM functions as a complete entity, hosting all components, including its independent operating system, layered atop the virtualized hardware.

Container deployment era:

Container deployment

Containers are like Virtual Machines (VMs), but they share the same Operating System (OS) among applications, making them lighter. Each container has its own space for files, CPU, memory, and processes, similar to a VM. The cool part is, that containers can easily move around different clouds and Operating Systems because they're not tied to the underlying infrastructure.

conatiner toystory meme

Why container are becoming so popular?

These days containers have become so popular  because they provide extra benefits, such as:

  • Easy App Creation and Deployment: Making container images is simpler and quicker compared to using Virtual Machine (VM) images.
  • Continuous Development and Deployment: This lets you reliably and frequently build and deploy container images. If something goes wrong, you can quickly roll back to a previous image.
  • Separation of Dev and Ops: You create application container images before deploying them, keeping applications separate from infrastructure.
  • Observability: Provides info not just about the operating system but also about how the application is doing.
  • Consistent Environments: Your app runs the same whether it's on your computer, in testing, or in production.
  • Portability Across Platforms: Works on various systems like Ubuntu, RHEL, CoreOS, and in the cloud or on your server.
  • App-Focused Management: Shifts the focus from running an operating system on virtual hardware to running an app on an OS using logical resources.
  • Flexible Micro-Services: This breaks apps into smaller parts that can be easily managed and deployed, moving away from one big complicated setup.
  • Resource Isolation: Make sure your app performs predictably by keeping its resources separate.

What problems does it solve ?

Containers are like neat packages for your apps, making them easy to run. When your apps are running for real, you want to make sure these containers are looked after and that your apps stay up without any breaks. If one container stops, another should take over, right? Imagine if a system could take care of all this for you. Much simpler, right?

That's where Kubernetes steps in as the superhero! It gives you a toolkit to handle your apps' wild adventures. Kubernetes takes charge of scaling, rescues your app in case it falters, and even throws in some cool deployment tricks.

Thing Kubernetes provides you

Now here are some Kubernetes special powers 🪄

  • Service Discovery and Load Balancing: Kubernetes helps your apps connect and balance the workload. It can give each app a unique name or IP address and manage traffic so everything stays stable.
  • Storage orchestration: You can tell Kubernetes where to store your stuff – it could be on your computer, in the cloud, or somewhere else. It takes care of the details so you don't have to.
  • Easy Updates and Rollbacks: Describe how you want your apps to be, and Kubernetes makes it happen. It can gradually switch things up, like bringing in new containers or getting rid of old ones, all without causing chaos.
  • Smart Resource Use: Tell Kubernetes what your apps need in terms of power (CPU) and memory. It then cleverly fits them into the available space on your computer or server.
  • Self-Healing Magic: If an app messes up, Kubernetes jumps in. It restarts, replaces, or removes problem-causing apps and doesn't let them cause trouble until they're good to go.
  • Secret Keeper: Got secret info like passwords or special keys? Kubernetes can keep them safe and update them without making a fuss.
  • Batch Jobs Too: Not just for regular apps – Kubernetes can handle batch jobs and tasks for you, even replacing ones that misbehave.
  • Scaling Made Easy: Need more power or less? Just tell Kubernetes, and it scales your apps up or down with a snap – no tech hassle.

Architecture behind Kubernetes?

So here comes the building blocks of Kubernetes

k8s architecture meme

Haha got you but that’s an actual architecture behind the Kubernetes let me break it down into an easy diagram.

k8s architecture

Now let me demonstrate what each term do
But before that I’ll tell you what are pods ?
A pod is the smallest thing you can deploy in Kubernetes. It's like a tiny package that holds one or more containers, which are like software boxes. These containers work together, sharing space and talking to each other. So, a pod is just a team of containers that hang out together and help run your apps in Kubernetes. It's like the basic building block for getting stuff done in Kubernetes.

Control Plane

The control plane is responsible for container orchestration and maintaining the desired state of the cluster. It just acts Like a Captain of your containers. It has the following components:

*Kube-APIserver *

Think of the kube-api server as the big boss in a Kubernetes team. It's like the main office where everyone, including regular folks and important team players, goes to communicate. When you use a tool like Kubectl to handle the team's tasks, you chat with this big boss through a special language (HTTP REST APIs).

Now, inside the team, there are some fancy departments like the scheduler and controller. These guys have their secret language (gRPC) to talk directly to the big boss. Most of the time, it's like using English (HTTP REST APIs) when you're on the outside, but inside, they have their cool way of chatting.

etcd

In Kubernetes, etcd is like the brain – a smart database that helps the team find each other (service discovery) and stores important info. It's the go-to source for keeping everything in sync.

How does it work ??

In plain terms, when you use Kubectl to check details about a Kubernetes object, you're essentially fetching that info from etcd. Likewise, when you deploy something like a pod, etcd keep a record of it. Etcd is like the behind-the-scenes storage that holds all the key details about what's happening in your Kubernetes setup.

kube-scheduler

Think of the Kube-scheduler in Kubernetes as a sort of matchmaker for pods and worker nodes.

When you create a pod, you tell the scheduler what the pod needs, like how much CPU, memory, and other things. The scheduler's main job is to take this info and find the perfect spot (worker node) for the pod. It's like a super-smart assistant, making sure each pod gets the right home in the cluster that fits its needs.

Kube-controller-manager

Think of the Kube controller manager in Kubernetes as the boss overseeing all the controllers.

Now, controllers are like managers for different things in Kubernetes, such as pods, namespaces, jobs, and replicasets. They make sure everything is running smoothly. Even the Kube scheduler, which is like the team's scheduler, is managed by this boss – the Kube controller manager. So, it's the one in charge of keeping all the different parts of the Kubernetes team working together seamlessly

Cloud-controller-manager

When Kubernetes is deployed in cloud environments, the cloud controller manager acts as a bridge between Cloud Platform APIs and the Kubernetes cluster.

This way the core Kubernetes core components can work independently and allow the cloud providers to integrate with Kubernetes using plugins.

Kubernetes Worker Node Components

Kubelet

The Kubelet is like the worker on each team member's computer in the Kubernetes squad. It's not a container itself, instead, it's like a dedicated helper running in the background, managed by systemd.

What it does is pretty important. It registers each team member's computer with the main hub (API server) and pays close attention to the team's instructions (podSpec). This special set of instructions says what containers should be in the team, their limits (like CPU and memory), and other important details like environment variables, storage spaces, and labels. So, the Kubelet is the go-to guy making sure everything runs smoothly on each team member's computer.

Kube proxy

Think of Kube-proxy as the guardian on each team member's computer in Kubernetes. It's like a quiet helper running in the background, making sure that when you ask for a bunch of team members (pods) using just one team name (Service), everything works smoothly. It handles load balancing and service discovery, ensuring messages reach the right team members. It's the traffic manager for the team.

So how does this guardian work ?

Kube proxy talks to the API server to get the details about the Service (ClusterIP) and respective pod IPs & ports (endpoints). It also monitors for changes in service and endpoints.

Container Runtime

The container runtime in Kubernetes is like the engine in every car of the group. It pulls images of the cars (container images) from the parking area (container registries), gets the cars running, assigns parking spots, and takes care of their well-being on the road (container lifecycle). Essentially, it makes sure everything runs smoothly for the containers on each car in the group.


Keep an eye out for upcoming concepts that will be introduced soon along with my learning journey 😊.

Top comments (0)