DEV Community

Cover image for Kubernetes: Whats, Whys, and Hows of Kubernetes with Demonstration
Lovepreet Singh
Lovepreet Singh

Posted on

Kubernetes: Whats, Whys, and Hows of Kubernetes with Demonstration

📍 Why we need Kubernetes?

🙂 When It comes to heavy traffic on our website then we need to scale our App to handle more traffic. Also, It was a challenge earlier to make the App platform independent to ease the testing or usage on other machines.

🎉 Docker came as our life saver which made the dependencies and App package in a single container along with Hardware resources allocated for that container.

Docker Made the following things easy:-

  • We can run our App in containers that are machine independent
  • It made the implementation of Micro-services Architecture easy
  • Load Balancers can be used to distribute the load between the containers (For ex. Software Load balancers like NGINX)

🎯 Now we know we can balance the load between the containers as:-

Nginx and Docker

Wohoo Meme

😅 But But But!!! What If the load on one container increases? Then we need the Scaling of containers. And What if containers need to communicate with each other?

😌 These challenges are overcome using Container management or orchestration tool called Kubernetes (Also known as K8s).

📍 What is Kubernetes?

Kubernetes is a Container management tool which provides us the various features to manage the containers. It facilitates the Micro-services Architecture.

Monolithic and Micro-services Architecture

🔥 Features of K8s:-

  • Automatic Bin-packing (It allocates the required resources to the container automatically)
  • Load Balancing (If one node is down or having high traffic then the incoming traffic will be re-directed to another container)
  • Self Healing
  • Batch Execution
  • Horizontal Scaling

🤜 Don't worry, we'll look into it if you haven't understood some.

Docker meme

📍 Architecture of Kubernetes

Kubernetes Architecture

🙂 It follows the Master-Slave Architecture where the manifest file (YAML file that describes each component or resource of your deployment and the state you want your cluster to be in once applied) is stored inside the Master. K8s API and Master interacts with the Nodes and deploys the pods.

👉 Pods are the fundamental units of k8s. Containers always resides inside the pods and Containers don't have their networking means they don't have their own IP or address, They will share the pod's IP and address.

Kubernetes or k8s Architecture

  • Master controls the cluster and the nodes inside it
  • Nodes hosts the containers inside them and containers are inside the separate pods.
  • In the above picture we have one cluster having three nodes

📍 Setup of Minikube and What is KubeCTL?

Production cluster setup

🙂 In the above picture you can see that in production we have many resources such that we can make different clusters. But to test on our local machine we can use minikube.

Minikube

🎯 Minikube will create a virtual box in our machine and Node will run in that virtual Box (Virtual Node). In other words, Minikube is a one node k8s cluster that runs in a virtual box in our laptop.

😅 To interact with the cluster we need KubeCTL (Kubernetes command line tools)

k8s architecture

😇 In the above picture you can see that Master process communicate with the API server. It does that either using UI, API or CLI (KubeCTL). Note that we are talking about the virtual node in the local machine.

😌 KubeCTL can be used for both the Local machine Node or the cloud cluster.

Kubectl usage

Note:- You need to install HyperKit or some kind of Hypervisor first.

  • After Installation of MiniKube, Type Minikube in the CommandLine

Minikube

  • Now, type Minikube start but make sure you start the Docker first.

Now, you can use Minikube and Follow this Cheat Sheet for Basic commands.


🎉 Follow for more interesting blogs. Drop a like and save for future.

Latest comments (7)

Collapse
 
to_vn2 profile image
Tạo Hà Văn

ối dồi ôi

Collapse
 
yashmeshram profile image
Yash Meshram

Easily explained.

Collapse
 
mjsf1234 profile image
mrityunjay saraf

Insightful content. keep it up brother 👏👏

Collapse
 
arpitpatel25 profile image
Arpit Patel

A great theoretical explanation on Kubernetes.

Collapse
 
yk_dhawan_519349b771d0dba profile image
YK DHAWAN

It was nice read.

Collapse
 
light_seekern profile image
Taha Syed

Good 😊😊

Collapse
 
vaibhav68849256 profile image
Vaibhav Khandare

Helpful