4.5.12 · HinglishSoftware Engineering

Kubernetes — pods, deployments, services, ingress (concepts)

2,032 words9 min readRead in English

4.5.12 · Coding › Software Engineering


Kubernetes exist KYUN karta hai?

Core loop hai reconciliation loop:

Ek controller gap ko watch karta hai aur action leta hai jab tak gap zero na ho jaye. Yahi reason hai ki Kubernetes declarative hai, imperative nahi: tum "container start karo" nahi bolte, tum bolte ho "mujhe 3 copies running chahiye" aur yeh use maintain karta hai.


Chaar objects (bottom → top)

1. Pod — the atom

HOW pods behave karte hain: Pods ephemeral aur mortal hote hain. Inhe ek Pod IP milta hai, lekin agar ek Pod mar jaye toh use same identity ke saath resurrect nahi kiya jata — ek naya Pod ek naye IP ke saath appear hota hai. Yeh sabse important fact hai:

2. Deployment — Pods ki copies manage karta hai

HOW rolling update kaam karta hai (safety derive karo): Tumhare paas replicas = R hai. Update strategy mein do knobs hain:

  • maxUnavailable = ek time pe kitne Pods down ho sakte hain
  • maxSurge = kitne extra Pods temporarily create ho sakte hain

Update ke dauran available Pods ki sankhya satisfy karti hai:

Toh capacity kabhi se neeche nahi giregi → zero-downtime upgrade. Agar nayi version broken hai, tum rollback karte ho aur Deployment purani ReplicaSet ke Pods dobara create kar deta hai.

3. Service — stable address + load balancing

Service types (har ek reachability add karta hai):

  • ClusterIP (default): sirf cluster ke andar reachable. Internal microservice-to-microservice.
  • NodePort: har node ki IP pe same port kholta hai → bahar se reachable, thoda crude.
  • LoadBalancer: cloud se ek external load balancer maangta hai public IP ke saath.

4. Ingress — edge pe smart HTTP router

Figure — Kubernetes — pods, deployments, services, ingress (concepts)

Poora request path (Feynman-level)


Common mistakes (steel-manned)


Flashcards

Kubernetes mein sabse chhota deployable unit kya hai?
Ek Pod (ek ya zyada containers jo network namespace aur storage share karte hain).
Pod ka IP hardcode kyun nahi karna chahiye?
Pods ephemeral hote hain; restart/reschedule/scale karne se naye Pod ko naya IP milta hai. Stable address ke liye Service use karo.
Deployment kya manage karta hai aur kis zariye?
Identical Pods ka ek set, ek ReplicaSet ke zariye, desired replica count maintain karta hai aur rolling updates/rollbacks handle karta hai.
Service ko kaise pata chalta hai ki traffic kaun se Pods ko bhejna hai?
Label selector ke zariye; yeh matching healthy Pods ke IPs (Endpoints) track karta hai aur unke beech load-balance karta hai.
Teeno main Service types aur unki reach batao.
ClusterIP (sirf internal), NodePort (har node ki IP pe port), LoadBalancer (external cloud LB public IP ke saath).
Ingress kya karta hai jo Service nahi kar sakta?
L7 (HTTP) routing by host/path aur TLS termination, bahut saari Services ko ek entry point ke zariye expose karna.
Rolling update ki safety kaun se do knobs control karte hain?
maxUnavailable (kitne Pods down ho sakte hain) aur maxSurge (kitne extra Pods create ho sakte hain).
Reconciliation loop kya hai?
Kubernetes continuously desired state aur observed state ke beech gap close karne ke liye act karta hai (declarative model).
Har Service ke liye ek LoadBalancer ki jagah Ingress kyun use karein?
Har Service ke liye ek LB costly hai; Ingress ek single entry point deta hai jo URL se bahut saari Services route karta hai.
Actual Ingress rules kaun run karta hai?
Ek Ingress Controller (e.g. nginx, Traefik) — rules iske bina kuch nahi karte.

Recall Feynman: ek 12-saal ke bacche ko samjhao

Ek pizza shop imagine karo. Pods cooks hain — woh actually pizzas banate hain, lekin koi bhi cook beemar pad sakta hai aur naya le leta hai uski jagah. Deployment manager hai jo ensure karta hai ki hamesha, maan lo, 3 cooks kaam kar rahe hoon, aur ek-ek karke naye trainees ko train kare taki kitchen kabhi band na ho. Service shop ka phone number hai — yeh kabhi nahi badlta even when cooks badalte hain, aur tumhari call jo bhi cook free ho usse route karta hai. Ingress aage ka darwaza hai signs ke saath: "Pizza → kitchen, Drinks → bar", har customer ko sahi counter pe bhejta hai. Tum bas manager ko bolte ho "mujhe 3 cooks chahiye", aur Kubernetes hamesha ke liye yeh sach rakhta hai.

Connections

  • Containers and Docker — Pods containers wrap karte hain; images Docker/OCI se aati hain.
  • Microservices Architecture — Services + Ingress microservices ko wire karte hain.
  • Load Balancing — Services L4 LBs hain; Ingress L7 hai.
  • Declarative vs Imperative Programming — reconciliation loop declarative hai.
  • DNS — Service discovery aur Ingress host routing DNS pe depend karte hain.
  • CI-CD Pipelines — Deployments automated rolling releases enable karte hain.

Concept Map

works via

drives

manages Pods via

guarantees N

are

so never address directly

load balances to

handles

routes HTTP to

Kubernetes declarative robot

Reconciliation loop

Pod - smallest unit

Deployment

ReplicaSet

Service - stable address

Ingress

Ephemeral IPs change

Rolling update