Skip to main content

What is Kubernate | Explain Kubernate in depth

 

1. What is Kubernetes? (K8s)

  • Definition:
    Kubernetes (often written as K8s) is an open-source container orchestration platform.
    It automates the deployment, scaling, and management of containerized applications.

  • Why we need it:
    If you run just 1 container, Docker is enough.
    But in real projects, we run tens or hundreds of containers across multiple servers.
    Problems arise:

    • How to restart a failed container automatically?

    • How to scale containers up/down?

    • How to update apps without downtime?

    • How to expose services to the outside world?

    Kubernetes solves all of these by acting like a “container manager” for the whole cluster.

  • Key features:

    1. Container Scheduling → Decides on which node a container should run.

    2. Self-healing → Restarts failed containers automatically.

    3. Scaling → Increases or decreases the number of containers based on demand.

    4. Rolling Updates & Rollbacks → Updates apps without downtime.

    5. Service Discovery & Load Balancing → Distributes traffic to the right containers.

  • Real-life analogy:
    Think of Kubernetes like an airport traffic control system — instead of planes and runways, it manages containers and servers to make sure everything runs safely and efficiently.


2. What is kubectl?

  • Definition:
    kubectl (pronounced cube-control or kube-cuddle) is the command-line tool used to interact with a Kubernetes cluster.

  • Purpose:
    It sends commands (using Kubernetes API) to manage resources such as pods, deployments, and services.

  • Common examples:

    bash

    kubectl get pods # List pods kubectl describe pod xyz # Detailed info of a pod kubectl apply -f file.yml # Create/update resources from a YAML file kubectl delete pod xyz # Delete a pod
  • Analogy:
    If Kubernetes is a restaurant kitchen, kubectl is the waiter taking orders from customers (you) and passing them to the chef (K8s) to execute.


3. What is Minikube?

  • Definition:
    Minikube is a tool that lets you run a single-node Kubernetes cluster locally on your laptop.

  • Purpose:
    It’s perfect for:

    • Learning Kubernetes

    • Testing small workloads

    • Running labs without using cloud services (AWS/GCP/Azure)

  • How it works:

    • It creates a virtual machine or container on your system.

    • Installs Kubernetes inside it.

    • Lets you access it with kubectl.

  • Key features:

    • Runs Kubernetes locally in minutes.

    • Has add-ons like Ingress, metrics-server, dashboard.

    • Supports multiple drivers (Docker, Hyper-V, VirtualBox, etc.).

  • Analogy:
    If Kubernetes in production is a big city, Minikube is a miniature model of that city — great for learning and experiments.


4. How these three fit together

  1. Minikube → Creates your local Kubernetes cluster.

  2. Kubernetes → The platform running your containers inside that cluster.

  3. kubectl → The remote control to interact with Kubernetes.

Flow:
You → run command in kubectl → sends request to Kubernetes API Server in Minikube → Kubernetes manages your containers.


1) Setup — step-by-step (copy/paste, run as admin when needed)

A. Enable WSL2 & install Ubuntu (PowerShell as Administrator)

powershell

# On Windows 11 (PowerShell Admin) wsl --install -d ubuntu # If WSL is already installed but older: wsl --update wsl --set-default-version 2

See Microsoft WSL docs for details. Microsoft Learn+1

After install, open the Ubuntu terminal and run:

bash

# inside WSL (Ubuntu) sudo apt update && sudo apt upgrade -y sudo apt install -y curl apt-transport-https ca-certificates gnupg lsb-release

B. Install Docker Desktop on Windows (enable WSL integration)

  1. Download & install Docker Desktop for Windows, follow installer.

  2. In Docker Desktop settings → Resources → WSL Integration → enable integration for your Ubuntu distro.

  3. (Optional) In Settings → Kubernetes → Enable Kubernetes if you want Docker Desktop's single-node K8s.
    Docs: Docker Desktop + WSL instructions. Docker Documentation+1

After installation, confirm Docker works inside WSL:

bash

# inside WSL docker version docker run --rm hello-world

C. Install kubectl (use WSL)

Recommended: install kubectl in your WSL distro (Linux binary):

bash

# inside WSL (Linux) curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl kubectl version --client

Official kubectl install docs. Kubernetes

D. Install Minikube (in WSL)

bash

# inside WSL curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube minikube version

Start a cluster using the Docker driver (works well when Docker Desktop WSL integration is enabled):


minikube start --driver=docker --cpus=2 --memory=4096 # verify kubectl get nodes kubectl cluster-info

Minikube docs & drivers reference. minikube+1

Alternative: kind for CI or reproducible clusters (kind create cluster). kind.sigs.k8s.io

E. Install Helm (package manager)

bas
# inside WSL (use official install script) curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash helm version

Helm docs. helm.sh


2) First hands-on lab — Pods → Deployment → Service (30–40m)

Create two YAML files:

deployment.yaml

yaml

apiVersion: apps/v1 kind: Deployment metadata: name: hello-deploy spec: replicas: 3 selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: hashicorp/http-echo:0.2.3 args: - "-text=Hello from Kubernetes" ports: - containerPort: 5678

service.yaml

yaml
\
apiVersion: v1 kind: Service metadata: name: hello-svc spec: type: NodePort selector: app: hello ports: - port: 80 targetPort: 5678 nodePort: 30080

Apply and test:

bash

kubectl apply -f deployment.yaml -f service.yaml kubectl get pods,svc # to access (minikube) minikube service hello-svc --url # or on Docker Desktop with NodePort, access localhost:30080 curl $(minikube service hello-svc --url)

Explain: replicas, selectors, pod template, service types.


3) Ingress (expose app on a hostname) (30–40m)

Enable the NGINX Ingress controller (Minikube):

bash

minikube addons enable ingress # verify kubectl get pods -n ingress-nginx

Create ingress.yaml:

yaml

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: hello-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: hello.local http: paths: - path: / pathType: Prefix backend: service: name: hello-svc port: number: 80

Point hello.local to your minikube IP. On Windows edit C:\Windows\System32\drivers\etc\hosts:

lua

<minikube-ip> hello.local

Then access http://hello.local in the browser. Minikube ingress guide. Kubernetes


4) ConfigMap & Secret (10–15m)

configmap.yaml

yaml

apiVersion: v1 kind: ConfigMap metadata: name: hello-cm data: MESSAGE: "Hello from ConfigMap"

Mount or pass as env var in pod spec. For secrets, use kubectl create secret generic.


5) Persistent storage (20–30m)

For local labs use a simple PVC backed by minikube hostPath storage class.

pvc.yaml

yaml

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: demo-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi

Use in a pod spec (volumeMount) to show data persistence across pod restarts.


6) Autoscaling & metrics (20–30m)

Enable metrics-server in minikube:

bash

minikube addons enable metrics-server kubectl top nodes kubectl top pods

Create HPA:

bash

kubectl autoscale deployment hello-deploy --cpu-percent=50 --min=1 --max=5

Docs: metrics-server and minikube addons. KubernetesGitHub


7) Rolling updates & rollback (10–15m)

Update the image:

bash

kubectl set image deployment/hello-deploy hello=hashicorp/http-echo:0.2.4 kubectl rollout status deployment/hello-deploy # rollback kubectl rollout undo deployment/hello-deploy

8) Helm + chart demo (20–30m)

Install a chart (nginx example):

bash

helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update helm install my-nginx bitnami/nginx

Helm docs. helm.sh


9) CI/CD demo idea (30–45m)

Flow:

  1. Git push → GitHub Actions builds Docker image (use GitHub-hosted runner or self-hosted in Windows).

  2. Push image to Docker Hub / GHCR.

  3. Run kubectl set image or helm upgrade to deploy new image.

(If students use local Docker Desktop, they can docker build and kubectl set image directly.)


10) Troubleshooting & useful commands (cheat-sheet)

Common commands:

bash

kubectl get pods,svc,deploy,rs -A kubectl describe pod <pod> kubectl logs <pod> [-c container] kubectl exec -it <pod> -- /bin/sh kubectl get events --sort-by='.lastTimestamp' kubectl top pods minikube logs minikube dashboard # opens UI kubectl apply -f <file> kubectl delete -f <file> kubectl rollout status deployment/<name> kubectl rollout undo deployment/<name>

Comments

Popular posts from this blog

Uncontrolled form input in React-JS

  Uncontrolled form input in React-JS? If we want to take input from users without any separate event handling then we can uncontrolled the data binding technique. The uncontrolled input is similar to the traditional HTML form inputs. The DOM itself handles the form data. Here, the HTML elements maintain their own state that will be updated when the input value changes. To write an uncontrolled component, you need to use a ref to get form values from the DOM. In other words, there is no need to write an event handler for every state update. You can use a ref to access the input field value of the form from the DOM. Example of Uncontrolled Form Input:- import React from "react" ; export class Info extends React . Component {     constructor ( props )     {         super ( props );         this . fun = this . fun . bind ( this ); //event method binding         this . input = React . createRef ();...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

JDBC Database Connectivity using JSP and Servlet, Database connectivity on Java

JDBC Database Connectivity using JSP and Servlet, Database connectivity on Java JDBC:-   JDBC means Java database connectivity, it is used to connect from the front-end(application server) to the back-end(database server) in the case of Java web application. The database provides a set of tables to store records and JDBC will work similarly to the  bridge between the database table and application form. 1)  Class.forName("drivername")  // Manage Drive         Class.formName("com.mysql.jdbc.Driver");  // MYSQL      Class.forName ("oracle.jdbc.driver.OracleDriver"); //Oracle 2)  Manage Connection String     It establish connection from application server to database server, Java provide DriverManage class and getConnection that will return Connection object.    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename","username","password"); 3)  Manage Statement to...