Part 4 · Reliability ও Security 📖 ১৩ মিনিট পড়া 📝 ২০টি কুইজ

VMs vs Containers

Modern deployment-এর দুই কেন্দ্রীয় technology।

📝 কুইজে যান

আপনি একটি ফ্ল্যাট ভাড়া নিতে চান। দুটি option: (১) সম্পূর্ণ আলাদা বাড়ি — নিজের electric, water, kitchen, bathroom। (২) বড় building-এ apartment — আলাদা কিন্তু shared resources। প্রথমটা VM, দ্বিতীয়টা container। দুটোর জায়গাই আছে — কোনটা কখন?

Virtual Machine (VM) কী?

VM = একটি physical server-এ chalano হয় multiple "virtual" computer। প্রতিটি VM-এর own OS, kernel, libraries, এবং applications।

কাঠামো

[Physical Server (Hardware)] ↓ [Hypervisor (VMware, KVM, Hyper-V)] ↓ [VM 1: Linux] [VM 2: Windows] [VM 3: Linux] ↓ ↓ ↓ [App 1] [App 2] [App 3]

Hypervisor

Hardware-এর সাথে VM-গুলোকে যোগ করে।

  • Type 1 (Bare-metal): Hardware-এ সরাসরি — VMware ESXi, Xen, Hyper-V।
  • Type 2 (Hosted): OS-এর উপর — VirtualBox, VMware Workstation।

সুবিধা

  • Strong isolation — security বাড়ে।
  • Different OS run।
  • Mature technology।
  • Hardware-level virtualization।

অসুবিধা

  • Heavy — প্রতি VM-এ full OS।
  • Slow boot (minutes)।
  • Resource overhead।
  • OS license cost।

Container কী?

Container = একটি lightweight, isolated process unit যা host-এর OS kernel share করে কিন্তু own filesystem, libraries ও config-এ চলে।

কাঠামো

[Physical Server / VM] ↓ [Host OS + Kernel] ↓ [Container Runtime (Docker, containerd)] ↓ [Container 1] [Container 2] [Container 3] ↓ App + libs ↓ App + libs ↓ App + libs

মূল technology

  • Linux Namespaces: Process isolation।
  • Cgroups: Resource control (CPU, memory)।
  • Layered filesystem: Image-এর efficient storage।

সুবিধা

  • Lightweight — KB/MB scale।
  • Fast boot (seconds)।
  • Efficient resource use।
  • "Build once, run anywhere"।
  • DevOps-friendly।

অসুবিধা

  • Same OS kernel share — Linux container Windows-এ direct চলে না (WSL ছাড়া)।
  • Isolation VM-এর চেয়ে weak।
  • Stateful workload challenging।

VM vs Container — বিস্তারিত তুলনা

Virtual Machine

  • Full OS per VM
  • GB scale
  • Boot in minutes
  • Strong isolation
  • Hypervisor
  • Multiple OS support
  • Heavy resource use

Container

  • Shared OS kernel
  • MB scale
  • Boot in seconds
  • Process-level isolation
  • Container runtime
  • Same OS family
  • Lightweight

Docker — Container-এর জনপ্রিয়তা

Docker (২০১৩) container-কে mainstream করল। Standard format + tooling।

Docker terminology

  • Image: Read-only template (ছবি)। App + dependencies।
  • Container: Image-এর running instance।
  • Dockerfile: Image build instruction।
  • Registry: Image storage (Docker Hub, ECR, GCR)।
  • Compose: Multiple container orchestration (dev)।

Sample Dockerfile

FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD ["node", "server.js"]

Kubernetes — Container Orchestration

Production-এ ১০০-১০০০ container manage করা impossible manually। Kubernetes (K8s) এই সমস্যা solve।

Features

  • Auto-scaling: Load অনুযায়ী container count।
  • Self-healing: Crashed container restart।
  • Rolling deployment: Zero-downtime updates।
  • Load balancing: Service-এর সামনে।
  • Service discovery: Container-এর IP find।
  • Config management: ConfigMap, Secret।

Core concepts

  • Pod: Smallest unit — one or more container।
  • Node: Physical/virtual machine।
  • Cluster: Multiple node।
  • Deployment: Pod replica management।
  • Service: Pod-গুলোর stable network endpoint।
  • Ingress: External traffic entry।

কখন কোনটা?

VM ভালো

  • Multiple OS দরকার (Linux + Windows)।
  • Strong isolation (multi-tenant)।
  • Legacy application।
  • Long-running, stable workload।
  • Specific hardware emulation।

Container ভালো

  • Microservice deployment।
  • CI/CD pipeline।
  • Scaling fast।
  • DevOps culture।
  • Cloud-native app।

Hybrid: Container in VM

আজকের cloud-এ standard — VM-এ Kubernetes node, K8s container deploy করে। দুটোর benefit।

Security Considerations

  • VM: Hypervisor escape rare; strong isolation।
  • Container: Kernel share — kernel exploit risk। Minimal image use করুন।
  • Image scanning: Vulnerable dependencies detect।
  • Runtime security: Falco, runtime detection।
  • Read-only filesystem: Container-এ অপ্রয়োজনীয় write এড়ান।
  • Non-root user: Container root চালালে security risk।

বাস্তব উদাহরণ

  • Google: Borg (২০০৩-এ — K8s-এর ancestor)।
  • Netflix: AWS EC2 (VM) + container hybrid।
  • Spotify: Kubernetes-on-GCP।
  • WhatsApp: FreeBSD VM-এ Erlang process।

সাধারণ ভুল ধারণা

  1. "Container = lightweight VM": না — fundamentally different (kernel share)।
  2. "Container always better": Use case-অনুযায়ী।
  3. "K8s small project-এর জন্যও": Overkill — single container Docker যথেষ্ট।
  4. "Container security VM-এর সমান": না — weaker isolation।

Best Practices

  • Container image minimal (Alpine, distroless)।
  • Multi-stage build — final image ছোট।
  • Non-root user-এ চালান।
  • Secrets environment variable নয় — mount korुন।
  • Health check + liveness/readiness probe।
  • Resource limit set।
  • Image scanning automate।

📌 চ্যাপ্টার সারমর্ম

  • VM = full OS, hypervisor; heavy কিন্তু strong isolation।
  • Container = shared kernel; lightweight, fast।
  • Docker mainstream করেছে; Kubernetes orchestration।
  • Modern cloud — VM-এ container (hybrid)।
  • Security: minimal image, non-root, scan।