ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
App ၁၀ ခု run နေတဲ့ cluster မှာ Service LoadBalancer type ၁၀ ခု create လုပ်ရင် cloud load balancer ၁၀ လုံး (cost ၁၀ ဆ) ဖန်တီးရမှာပါ — မကုန်ကျမလိုချင်ပါဘူး။ Ingress က load balancer တစ်ခုတည်းပဲ ဖန်တီးပြီး, domain (`api.example.com`, `app.example.com`) ဒါမှမဟုတ် path (`/api`, `/app`) ပေါ်မူတည်ပြီး correct Service ဆီကို route လုပ်ပေးပါတယ် — 'ဟိုတယ် front desk' လိုမျိုးပါ, guest တစ်ယောက်ချင်းကို ဘယ်အခန်းသွားရမလဲ ညွှန်ပြပေးသလိုပါပဲ။ Ingress ကို အလုပ်လုပ်ဖို့ Ingress Controller (nginx-ingress, Traefik ကဲ့သို့) cluster ထဲ install ထားရပါမယ်.
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Ingress rule ထဲမှာ `api.example.com` → `api-service`, `app.example.com` → `frontend-service` ဆိုပြီး route ချထားနိုင်ပါတယ် — TLS/HTTPS certificate ကိုလည်း Ingress level မှာ centralize ထားနိုင်ပါတယ် (Service တစ်ခုချင်းစီမှာ cert ထားစရာမလို)။ Local minikube မှာ Ingress Controller ကို `minikube addons enable ingress` နဲ့ enable လုပ်ရပါမယ်.
အတူတူ ကြည့်မယ်
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-service
port:
number: 8080$ kubectl get ingress app-ingress
NAME CLASS HOSTS ADDRESS PORTS
app-ingress nginx app.example.com,api.example.com 192.168.1.5 80၅ မိနစ် စမ်းကြည့်
`minikube addons enable ingress` ကို run ပြီး, အထက်က Ingress rule ကို (host ကို local testing domain ပြောင်းပြီး) apply လုပ်ကြည့်ပါ။
သတိလေးတစ်ချက်
Ingress class (nginx, traefik, စသည်) အမျိုးမျိုးရဲ့ annotation syntax က မတူညီပါ — documentation ကို သင့် Ingress Controller အလိုက် သေချာ ဖတ်ပါ။