Learn 🧠 All Concepts (20) 🤖 What is an LLM? 📚 RAG Explained ⚡ AI Agents 💻 Run AI Locally 🇮🇳 AI in India 📖 Learn Tracks 🔧 DevOps Track ⚙️ AI Ops Track 🗺️ AI Engineer Roadmap
Tools 🔧 AI Tools Directory 🔓 Open Source AI ⭐ Top GitHub Repos ✦ Claude Skill Repos 🚀 Ready-to-Deploy Projects
Build 🏗️ Build Hub 🎯 Master Prompts 🧩 RAG Agents 🚀 App Megaprompts
Workflows ⚡ All Workflows (22) 🎥 Text to Video 🎞️ Image to Video 🔊 Text to Speech ♻️ Automation
Resources 🧪 Colab Notebooks ⚙️ n8n Workflows 📈 Algo Trading 💰 Passive Income
🗂️ Browse All Topics About AItheGuru
Learn DevOps Suresh conducts the orchestra
DevOps Ch 5 / 10 Advanced
🎼

Suresh conducts the orchestra

Kubernetes — orchestrating dozens of containers like a maestro

⏱ 15 min 5 commands 4 takeaways
🎼
In this chapter
Suresh
Senior DevOps engineer at a Mumbai fintech
The story

Suresh had been running Docker containers for two years. His team had 20 microservices. Each one was a Docker container. Life was manageable.

Then Black Friday happened. Traffic increased 10x in one hour. Some containers crashed under load. Others were using too much memory and killing neighbour containers. The payment service went down for 11 minutes. ₹3 crore in lost transactions.

His manager called. "Suresh, we need Kubernetes."

Suresh had heard of Kubernetes. He'd been avoiding it because everyone said it was complicated. But after Black Friday, complicated was better than ₹3 crore.

What is Kubernetes?

Imagine you're the music director of a 50-piece orchestra. Each musician is a Docker container. Without coordination, they play their own notes at their own tempo — chaos. Kubernetes is the conductor who keeps everyone in sync, tells each musician when to play, when to rest, and quickly finds a replacement when someone falls sick.

Kubernetes (K8s) is a system that:

- Automatically restarts containers if they crash

- Scales up (adds more containers) when traffic increases

- Scales down (removes containers) when traffic is low

- Distributes traffic across healthy containers

- Replaces unhealthy containers without downtime

The key building blocks

Pod — the smallest unit. Usually one container. Like one musician.

Deployment — describes how many pods you want and what they should run. Like the sheet music for a section of the orchestra.

Service — a stable address that routes traffic to your pods. Pods come and go, but the Service address stays the same.

Ingress — the front door. Routes external traffic to the right service.

A simple Kubernetes deployment

```yaml

deployment.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: payment-service

spec:

replicas: 3 # Run 3 copies of this container

selector:

matchLabels:
  app: payment

template:

metadata:
  labels:
    app: payment
spec:
  containers:
  - name: payment
    image: myregistry/payment:v2.1
    ports:
    - containerPort: 8080
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"

```

```bash

Apply the deployment

kubectl apply -f deployment.yaml

See your pods running

kubectl get pods

Scale up to 10 replicas instantly

kubectl scale deployment payment-service --replicas=10

See logs from a pod

kubectl logs pod-name

Get inside a running container

kubectl exec -it pod-name -- bash

```

What happened on the next Black Friday

Suresh set up Kubernetes with Horizontal Pod Autoscaler — it watches CPU usage and automatically adds more pods when load increases.

```yaml

apiVersion: autoscaling/v2

kind: HorizontalPodAutoscaler

metadata:

name: payment-hpa

spec:

scaleTargetRef:

name: payment-service

minReplicas: 3

maxReplicas: 50

metrics:

- type: Resource

resource:
  name: cpu
  target:
    averageUtilization: 70

```

When Black Friday traffic hit, K8s automatically scaled from 3 pods to 31 pods in 90 seconds. Payment service stayed up. Zero downtime. Zero manual intervention.

Suresh watched it happen on his dashboard, drinking chai, not panicking for the first time in three years.

The honest truth about Kubernetes

K8s has a steep learning curve. Don't run it for a small app — it's overkill. Use it when you have multiple services, need autoscaling, or require zero-downtime deployments. Managed services like GKE (Google), EKS (AWS), and AKS (Azure) remove most of the operational pain.

Start with Docker Compose. Graduate to Kubernetes when you feel the pain that K8s solves.

Key takeaways

Kubernetes orchestrates multiple containers — restarts, scales, and balances them automatically

Core objects: Pod (one container), Deployment (desired state), Service (stable address)

Horizontal Pod Autoscaler scales your app automatically based on load

Use managed K8s (GKE/EKS/AKS) in production — avoid running it yourself

Commands from this chapter
$ kubectl apply -f file.yaml
Apply a configuration to the cluster
$ kubectl get pods
List all running pods
$ kubectl logs pod-name
View logs from a pod
$ kubectl scale deployment name --replicas=5
Manually scale a deployment
$ kubectl describe pod pod-name
Debug a problematic pod