What is Kubernetes & what is it used for?

If you came to this article, then you must be curious about Kubernetes. Maybe you heard about it from a friend, or you checked out the job listings and found out that Kubernetes is in much demand than anything right now.

Large Enterprises are creating so many resources to educate people because they want to automate and adopt such a great product available solving, most of their difficulties from the past 20 years.

You need to understand so many things before learning Kubernetes

What are the challenges?

Let’s suppose you made a small app. You completed it and want others to use the app. How would you upload it online so others can use it??  of course, you would store it on a shared web hosting(server). You don’t need too much space, and it’s very costly to buy a server of your own.

and there is no limit for your app, so it can ask the operating system for access to any file on disk or any network socket. 

 you are using so many libraries and the user needs to download so many resources to use your app and there are so many operating systems out there that can easily cause so many problems.

The Solution:

You can lock down your app in a container.

Containers > Containers are assigned resources that no other process can access, and they cannot access any resources from outside if they are not allowed.

So it’s like an agreement with the app that you can’t access the outer resources on your own, and you will get what you want inside your container and no one from outside will use your resources. 

Image Reference: Docker

Docker > The Container System: I bet that you may have heard about Docker somewhere. It was quite popular and still the most used option to make containers. with Docker you can bundle all of your resources and it is called a Docker Image, We don’t convert directly into a container to provide better portability.

 A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

These images convert into Containers when they run on the Docker Engine to provide portability, that’s why the docker containers can run on any OS and they are completely secure.

So Docker solved a lot of problems here and all the big enterprises are using Docker now.

________________________________________

Let’s get back to the app you made, so you containerized it with Docker and now Hola! it’s working fine. You know that there are a lot of containers in a container. so there will be tons of containers but they are secure and portable with the help of Docker. Now you want to update your app or just want to replicate the containers, How would you do it without any interruption of service??

How do you know that your application is working the exact way you want or you just want to change the version of a library it’s using, How are you going to manage it? 

Tada!  

We Give you Kubernetes:

                            Image Reference: Kubernetes

You are going to use docker just to package and distribute your application means a very short time, but you are going to run, scale, maintain and monitor every time.

What is Kubernetes?

Kubernetes is an open-source container orchestration engine for automating deployment, scaling, and management of containerized applications

This is the same tagline they are using on their website you may have seen it before, but now I guess it feels easy for you. However, the container orchestration engine sounds like a  complicated concept but only orchestration word making this complicated.

orchestration means ‘plan or coordinates the elements of (a situation) to produce the desired effect’  __Google Translate

________________

When it was made, Who made it?

It’s from Tech Giant Google, ya

Google Developers made Borg to deploy their new apps to the network of distributed servers all around the world. later it becomes so useful and they made an open-source project from Borg called Project-Seven which is later called Kubernetes Version 1.0

Kubernetes is managed by CNCF (Cloud Native Computing Foundation) backed by tech giants like Microsoft, Alibaba Cloud, and Amazon.

So Kubernetes is not a child’s play and it’s a very enterprise solution. 

Why Kubernetes?

Containers make applications easy to deploy but when the number of the container increases it’s really hard to arrange them and without a tool like Kubernetes it is not possible. it lets you define the complex containerized applications, and application can be easily moved from local development machines to the cloud.

Kubernetes Basics :

Container and Pods > Container is the smallest thing in Kubernetes, like atoms. a single container is called a container and more than one container grouped and running on a cluster are called pods. These Pods share their storage and network with Kubernetes configuration. Each pod has it’s own unique IP address with pods that can communicate to other pods in the cluster. 

For Example :  

  • Pod of Front-end
  • Pod of Back-end e.t.c

Cluster >  Each cluster must contain a master node and a few worker nodes. 

Master > Master is called the brain of Kubernetes, and it controls everything, schedule containers and many more. it contains an API server, scheduler, controllers e.t.c. It’s also called Control Plane.

Worker Node > Every worker node contains a kubelet and a Kube proxy(it handles the networking) and the node can be a physical or VM machine.

Image Reference: Better Programming

Kubernetes Cluster

NameSpaces >  You can also create multiple clusters in a single cluster for large apps.

Replica Sets > Replica Sets in Kubernetes are like the backup pods, and if anything happens with a pod or it gets crash, then a replica set will create a new pod with the same config. It also ensures that every pod must be running in the cluster.

Node > A node can be a physical or VM machine in a cluster, and it holds all the services that are needed by pods to run and it’s managed by the master component.

Deployments > Kubernetes deployment is like to describe the final product, you want to see in the result. Kubernetes deployments also allow us to upgrade our apps without downtime.

Kubelet > it’s a service agent that ensures that every node is running on a cluster and all the pods are running one the node. 

etcdetcd is a distributed key-value store that lets you store and share data across a distributed cluster of machines. Kubernetes uses etcd to store data about your cluster and share it across the Kubernetes control plane. 

Volumes > Let’s suppose that you want to keep some data safe, but it’s in a container and container keeps running and dying and replicating and you can’t store some permanent data in it, You can store the data on cloud volumes like Amazon and Google,

  1. Problem: But there is a problem that you have to configure the volume ID and storage type on every node, which means users have to configure this, and it’s very hard for the user to get this information.
  2. Solution: By Kubernetes, you can create a series of abstractions like a bridge between the user’s data to the cloud volumes, so that users don’t have to enter anything.

________________________________________

Some people are also calling Kubernetes, container scheduler. It’s true but Kubernetes do more than just scheduling the container.

What’s Container Scheduling?

 Image Reference: Xoriant

A scheduler is a tool or maybe a set of tools, which watch for the new pods that have been created all the time. The new container doesn’t have any node assigned. So the scheduler will try to find the best available node for pods to run on.

I hope, I explained to you the very basics of Kubernetes. Just try to understand it, it’ll be a roller-coaster ride for you, but the end result will be very satisfying. 

______________________________________

Let’s see how we can use the Kubernetes:

Kubernetes gives you two options, to manage your clusters.

  1. Web GUI Interface
  2. CLI (kubectl)

Web GUI Interface

  Image Reference: Kubernetes

You can deploy your app and can access the Web GUI interface out of the box, here you can manage and monitor the applications in Kubernetes GUI.

Command Line Interface

There is an official command-line tool, kubectl

This can also help you to deploy, manage and inspect the clusters, you can also generate the logs from here.

Install kubectl on macOS

you can easily install kubectl with homebrew, package manager on macOS. 

  1. Open the Terminal and Run This Command
     brew install kubectl 

       2. Check the installation by running this command and also ensures that you are running the latest version.

           kubectl version

Install kubectl on windows

you can install by downloading the latest version from Kubernetes Official website.

  1. First Install the Latest Version of kubectl 
  2. Add it to the binary PATH variables to access it globally from CLI.
  3. Then open the command prompt and run this command to ensures that kubectl is working.
   kubectl version

YAML

Kubernetes uses YAML for the configuration and you can use YAML directly to manipulate resources. its syntax is straightforward and human-readable.

Summary ________________________________________

You can’t understand Kubernetes without understanding all of these concepts, and maybe you have already realized that Kubernetes is not a single skill to learn, it’s a collection of tools to automate the maintenance of the containerized application. It reduces the cost and almost ends the need for humans to maintain the application, which means a lot of Job Cuts. It’s good to get ready for a robotic world. 

SHARE ON

The Author: Aashir Aamir Khan

What is Kubernetes & what is it used for?

You May Also Like

Leave a Reply

Your email address will not be published.