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

Project — GitOps-Lite Deploy Flow

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

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

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

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

GitOps ရဲ့ core idea က 'Git repository ကပဲ desired state ရဲ့ single source of truth' ဖြစ်ရမယ် ဆိုတဲ့ concept ပါ — cluster ရဲ့ actual state ကို git ထဲက YAML နဲ့ အမြဲ sync ထားပါတယ်။ Full GitOps tool (ArgoCD, Flux) ကို install/setup လုပ်ချိန်မရှိသေးရင်, basic version ကို script တစ်ခုနဲ့ simulate လုပ်ကြည့်လို့ရပါတယ် — git repository ကို clone/pull ပြီးမှ `kubectl apply -f .` လုပ်တဲ့ pipeline ပါ။ ဒီ concept ကို နားလည်ထားရင် ArgoCD/Flux လို tool ကို နောက်ပိုင်း လေ့လာဖို့ foundation ကောင်းပါတယ်.

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

Git repository ထဲမှာ `k8s/` folder ဖန်တီးပြီး, deployment/service YAML files အားလုံးကို အဲဒီထဲ commit ထားပါ — YAML ကို ပြင်ဖို့ လိုရင် `kubectl edit` ဒါမှမဟုတ် dashboard ကနေ တိုက်ရိုက် မပြင်တော့ဘဲ, git ထဲက file ကို ပြင်ပြီးမှ commit/push, ပြီးမှ `kubectl apply -f k8s/` (ဒါမှမဟုတ် CI/CD pipeline ကနေ auto-apply) လုပ်ပါတယ် — history/audit trail ရရှိပြီး, rollback ကို `git revert` နဲ့ ရှင်းရှင်းလင်းလင်း လုပ်နိုင်ပါတယ်.

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

bash
# Set up a k8s/ folder in your git repo
mkdir k8s
git add k8s/*.yaml
git commit -m "Add web-deployment manifests"
git push

# "Deploy" step — apply everything from the folder
kubectl apply -f k8s/

# Made a mistake? Revert the git commit, then re-apply
git revert HEAD
kubectl apply -f k8s/
You should see
$ git log --oneline k8s/
a1b2c3d Add web-deployment manifests

$ kubectl apply -f k8s/
deployment.apps/web-deployment configured
service/web-service unchanged

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

`k8s/` folder ထဲမှာ deployment/service YAML file ၂-၃ ခုကို commit ထားပြီး, တမင် mistake တစ်ခု (ဥပမာ - image tag မှား) commit ကြည့်ပါ — `git revert` နဲ့ ပြန်ပြင်ကာ `kubectl apply` ကို ထပ်ကြည့်ပါ။

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

ဒီ project က GitOps concept ကို 'အခြေခံ' အနေနဲ့ ပြသတာပါ — production မှာတော့ ArgoCD/Flux ကဲ့သို့ tool ကို သုံးမှ auto-sync, drift detection, secret encryption စတာတွေ ပါဝင်လာပါမယ်.

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

  • Cluster ထဲကို manual `kubectl edit` နဲ့ တိုက်ရိုက် ပြင်ပြီး, git ထဲက YAML ကို sync မလုပ်ခြင်း — cluster state နဲ့ git state ကွဲသွားပါတယ် ('config drift')
  • Secret (password) ကို git repository ထဲ plain text commit ခြင်း — GitOps concept ထဲမှာ Secret ကို encrypt (sealed-secrets, SOPS) လုပ်ထားရပါမယ်

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

`k8s/` folder ထဲမှာ deployment/service YAML file ၂-၃ ခုကို commit ထားပြီး, တမင် mistake တစ်ခု (ဥပမာ - image tag မှား) commit ကြည့်ပါ — `git revert` နဲ့ ပြန်ပြင်ကာ `kubectl apply` ကို ထပ်ကြည့်ပါ။

You'll know it worked when: $ git log --oneline k8s/ a1b2c3d Add web-deployment manifests $ kubectl apply -f k8s/ deployment.apps/web-deployment configured service/web-service unchanged

Project — GitOps-Lite Deploy Flow | Thuta Learning