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: - 
Container Scheduling → Decides on which node a container should run. 
- 
Self-healing → Restarts failed containers automatically. 
- 
Scaling → Increases or decreases the number of containers based on demand. 
- 
Rolling Updates & Rollbacks → Updates apps without downtime. 
- 
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: 
- 
Analogy: 
 If Kubernetes is a restaurant kitchen,kubectlis 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
- 
Minikube → Creates your local Kubernetes cluster. 
- 
Kubernetes → The platform running your containers inside that cluster. 
- 
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.
0) Prereqs (Windows 10/11)
Hardware virtualization ON in BIOS.
Admin PowerShell.
Optional but recommended: WSL2 + Ubuntu (wsl --install in admin PowerShell, reboot).
Install kubectl (one of):
winget install -e --id Kubernetes.kubectl
choco install kubernetes-cli
scoop install kubectl
Verify: kubectl version --client.
Kubernetes
1) Choose ONE local cluster
A) Docker Desktop (simplest)
Install Docker Desktop (Windows).
Open Settings → Kubernetes → Enable Kubernetes → Apply & Restart.
Wait until status shows Running. Docker also ships a kubectl on PATH.
Docker Documentation
Docker
B) Minikube (very popular for learning)
Install Docker Desktop or enable Hyper-V (Win Pro/Enterprise):
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All (reboot).
minikube
Start a cluster (pick a driver):
With Docker driver (works on Win Home via WSL2):
minikube start --driver=docker
With Hyper-V (Win Pro/Enterprise):
minikube start --driver=hyperv
You can set a default driver: minikube config set driver docker (or hyperv).
minikube
+2
minikube
+2
Tip: If you like ultra-light clusters inside WSL2, kind (Kubernetes-in-Docker) is great: choco install kind → kind create cluster (run inside WSL2).
Kind
+1
Verify your cluster (for any option):
kubectl cluster-info
kubectl get nodes
Create First Kubernate Apps:
1) Create folder k8s-lab or anyname
1) create two file deployment.yaml and service.yaml file
code of deployment.yaml file
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-deployment
spec:
replicas: 2 # Number of pods
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app-container
image: nginx:latest # Your app image
ports:
- containerPort: 80
🌍 Real-World Example: "TechForest App"
📂 Project Structure (Windows)
Create a folder (e.g., C:\node-k8s-app) and inside put:
1) package.json
2) server.js
3) Dockerfile
4) Build & Load Docker Image into Minikube (Windows)
Option A: Use Minikube’s image builder (recommended)
In PowerShell (in your project folder):
Option B: Use Docker inside Minikube
Enable Docker daemon inside Minikube:
5) Kubernetes YAML
Save this as node-app.yaml in C:\node-k8s-app\
6) Deploy to Minikube
Run in PowerShell:
7) Access the App
Option A: Open via Minikube
Option B: Port-forward
👉 Visit: http://localhost:8080
8) Test Endpoints
- 
http://localhost:8080/→ 🚀 Hello from Node.js + Express + Kubernetes on Windows!
 
- 
http://localhost:8080/health→{ "status": "ok" }
 
http://localhost:8080/ → 🚀 Hello from Node.js + Express + Kubernetes on Windows!
http://localhost:8080/health → { "status": "ok" }
 
 
 
 
0 تعليقات
POST Answer of Questions and ASK to Doubt