হোম/Roadmap/Chapter 5.01
Phase 5 · Chapter 5.01

Kubernetes Basics

Docker একটা container চালায়। Kubernetes ১০০০ container-কে cluster-এ self-healing, auto-scaling, rolling update দিয়ে চালায়।

Why k8s

Docker যেখানে থামে

  • Container crash করলে কে restart করবে? — k8s।
  • Traffic বাড়লে আরও replica কে চালাবে? — k8s।
  • New version deploy zero-downtime — k8s rolling update।
  • Multi-node cluster-এ load distribute — k8s scheduler।
Core Primitives

যে ৫টা জিনিস না জানলে চলবে না

  • Pod — smallest unit, ১ বা একাধিক container।
  • Deployment — Pod-এর desired state (replica count, image, rollout strategy)।
  • Service — Pod-গুলোর stable network endpoint।
  • Ingress — external HTTP traffic routing।
  • ConfigMap / Secret — config + sensitive data।
Deployment YAML

Iris API on k8s

yamlproduction
apiVersion: apps/v1
kind: Deployment
metadata:
  name: iris-api
  labels: { app: iris-api }
spec:
  replicas: 3
  selector:
    matchLabels: { app: iris-api }
  template:
    metadata:
      labels: { app: iris-api }
    spec:
      containers:
        - name: api
          image: ghcr.io/me/iris-api:v1.0.0
          ports: [{ containerPort: 8000 }]
          resources:
            requests: { cpu: "200m", memory: "256Mi" }
            limits:   { cpu: "1",    memory: "1Gi" }
          readinessProbe:
            httpGet: { path: /health, port: 8000 }
            initialDelaySeconds: 5
          livenessProbe:
            httpGet: { path: /health, port: 8000 }
            initialDelaySeconds: 15
Service + Ingress

Traffic ভেতরে আনো

yamlproduction
---
apiVersion: v1
kind: Service
metadata: { name: iris-svc }
spec:
  selector: { app: iris-api }
  ports:
    - port: 80
      targetPort: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: { name: iris-ing }
spec:
  rules:
    - host: api.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: iris-svc
                port: { number: 80 }
Daily Commands

kubectl cheat-sheet

bashproduction
kubectl apply -f deployment.yaml
kubectl get pods -w
kubectl logs -f deploy/iris-api
kubectl describe pod iris-api-xyz
kubectl exec -it iris-api-xyz -- /bin/sh
kubectl rollout status deploy/iris-api
kubectl rollout undo   deploy/iris-api
kubectl scale deploy/iris-api --replicas=5
Common Mistakes

Beginner traps

  • resources না দেয়া — pod node-এর সব memory খেয়ে ফেলে।
  • Readiness probe নেই — traffic crash-loop pod-এ যায়।
  • :latest tag — rollback অসম্ভব।
  • Secret YAML-এ plaintext — Sealed Secrets বা External Secrets use করো।
Practice

Local cluster

  1. kind বা minikube install করে cluster বানাও।
  2. Iris image push, deployment apply।
  3. kubectl port-forward দিয়ে test করো।
Takeaway

মনে রাখো

k8s কঠিন না — কঠিন হলো production-ready k8s। Pod / Deployment / Service থেকে শুরু করো, বাকিটা ধীরে।