Thuta Learning
ရှာဖွေရန်
BasicDevOpsintermediate

Pods — အခြေခံ Unit

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Pods — အခြေခံ Unit ကို ကြောက်စရာမလိုအောင် နားလည်မယ်
  • ကိုယ်တိုင် kubectl command/YAML ကို run ကြည့်တတ်မယ်
  • Real project ထဲမှာ ဒီ concept ကို ချက်ချင်း အသုံးချတတ်မယ်

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

Docker မှာဆိုရင် 'container' ကို တိုက်ရိုက် run ပါတယ် — Kubernetes မှာတော့ container ကို တိုက်ရိုက် run တာ မဟုတ်ပါဘူး၊ Pod ထဲမှာ ထည့်ပြီးမှ run ပါတယ်။ Pod တစ်ခုမှာ container တစ်ခု (အများဆုံးဖြစ်တဲ့ pattern) ဒါမှမဟုတ် ဆက်နွယ်ရင်းနှီးတဲ့ container အနည်းငယ် (ဥပမာ - main app + logging sidecar) ပါဝင်နိုင်ပါတယ်။ Pod ထဲက container တွေက network (IP address) နဲ့ storage ကို share ပါတယ် — 'အိမ်တစ်လုံးထဲက အခန်းတွေ' လိုမျိုးပါ။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Pod ကို YAML file နဲ့ define လုပ်ပြီး `kubectl apply -f pod.yaml` နဲ့ create လုပ်ပါတယ်။ Pod တစ်ခု crash သွားရင် (ဒါမှမဟုတ် node ပျက်သွားရင်) Kubernetes က ပြန် create ပေးနိုင်ပေမယ့် — original pod အဟောင်း 'ပြန်ရှင်' တာ မဟုတ်ဘဲ pod အသစ်တစ်ခု (IP address အသစ်နဲ့) ဖန်တီးပေးတာပါ — ဒါကြောင့် production မှာ pod ကို တိုက်ရိုက် run ခြင်းထက် Deployment (နောက် lesson) ကနေတစ်ဆင့် run ပါတယ်။

အတူတူ ကြည့်မယ်

yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-first-pod
spec:
  containers:
    - name: web
      image: nginx:latest
      ports:
        - containerPort: 80
You should see
$ kubectl apply -f pod.yaml
pod/my-first-pod created

$ kubectl get pods
NAME            READY   STATUS    RESTARTS   AGE
my-first-pod    1/1     Running   0          10s

၅ မိနစ် စမ်းကြည့်

အထက်က pod.yaml ကို file အနေနဲ့ save လုပ်ပြီး `kubectl apply -f pod.yaml` run ကြည့်ပါ — `kubectl get pods` နဲ့ status Running ဖြစ်လာအောင် ကြည့်ပါ။

သတိလေးတစ်ချက်

Pod ကို `kubectl apply -f pod.yaml` နဲ့ တိုက်ရိုက် create တာက learning အတွက်ပဲ လုပ်ပါ — production မှာ Deployment (self-healing ပါ) ကနေတစ်ဆင့် run ပါ။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Production app တွေကို Pod တိုက်ရိုက် run ခြင်း — Pod ပျက်ရင် ဘယ်သူမှ ပြန်ဖန်တီးမပေးပါ (Deployment သုံးမှ auto-recreate ရပါမယ်)
  • Pod ထဲက container တစ်ခုစီကို 'သီးခြား server' လိုမျိုး ထင်ခြင်း — အမှန်က IP/storage share နေတဲ့ 'အိမ်တစ်လုံးထဲက အခန်း' ပါ

အခု ကိုယ်တိုင် စမ်းကြည့်

အထက်က pod.yaml ကို file အနေနဲ့ save လုပ်ပြီး `kubectl apply -f pod.yaml` run ကြည့်ပါ — `kubectl get pods` နဲ့ status Running ဖြစ်လာအောင် ကြည့်ပါ။

You'll know it worked when: $ kubectl apply -f pod.yaml pod/my-first-pod created $ kubectl get pods NAME READY STATUS RESTARTS AGE my-first-pod 1/1 Running 0 10s

Pods — အခြေခံ Unit | Thuta Learning