Thuta Learning
AWS Advanced
ContainersDevOpsအဆင့်မြင့်

EKS နဲ့ ECS — ဘယ်အချိန် Kubernetes ကို ရွေးသင့်လဲ

AWS Advancedသင်ခန်းစာ 1445 မိနစ်

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

  • EKS control plane နဲ့ ကိုယ်တိုင် တာဝန်ယူရတဲ့ အပိုင်းကို ခွဲခြားနိုင်မယ်
  • Managed node group၊ Fargate profile၊ Karpenter နဲ့ Auto Mode ကို နှိုင်းယှဉ်နိုင်မယ်
  • IRSA နဲ့ EKS Pod Identity နဲ့ pod တွေကို IAM permission ပေးနိုင်မယ်
  • Upgrade cadence နဲ့ add-on တွေကြောင့် ဖြစ်တဲ့ operational load ကို ခန့်မှန်းနိုင်မယ်
  • Workload တစ်ခုအတွက် ECS၊ EKS သို့မဟုတ် Lambda ကို အကြောင်းပြချက်နဲ့ ရွေးနိုင်မယ်

ရိုးရိုးလေး ရှင်းပြမယ်

ရိုးရိုးလေး ရှင်းပြရရင်

ECS က AWS ကိုယ်ပိုင် container orchestrator ဖြစ်ပြီး EKS (Elastic Kubernetes Service) ကတော့ open-source Kubernetes ကို AWS က manage လုပ်ပေးတဲ့ ဗားရှင်းပါ။ နှစ်ခုလုံး 'container တွေကို ဘယ်မှာ run မလဲ၊ သေရင် ပြန်တင်၊ load balancer နဲ့ ချိတ်' ဆိုတဲ့ အလုပ်တူတူကို လုပ်ပါတယ်။

ကွာခြားချက်က ecosystem နဲ့ တာဝန်ပမာဏပါ။ Kubernetes မှာ Helm chart၊ operator၊ GitOps tool တွေ ထောင်ချီ ရှိပြီး cloud ပြောင်းလည်း API တူတူ သုံးနိုင်ပါတယ်။ ဒါပေမဲ့ version upgrade၊ add-on၊ node တွေကို ပိုပြီး ကိုယ်တိုင် ကိုင်ရပါတယ်။ ဥပမာ ပေးရရင် ECS က ပရိဘောဂ အပြည့်ပါတဲ့ တိုက်ခန်း ငှားတာဖြစ်ပြီး EKS က အခြေခံ အဆောက်အအုံ ပေးထားတဲ့ မြေကွက်မှာ ကိုယ်ကြိုက်သလို ဆောက်ရတာနဲ့ တူပါတယ် — လွတ်လပ်မှု ပိုရပေမဲ့ ထိန်းသိမ်းစရာလည်း ပိုများပါတယ်။

Problem → Why → Solution

ပြဿနာ — service ၃ ခုအတွက် platform team တစ်ခုလုံး လိုလာတာ

Developer ငါးယောက်ရှိတဲ့ startup တစ်ခုက 'industry standard ဖြစ်လို့' ဆိုပြီး API service ၃ ခုအတွက် EKS ကို ရွေးလိုက်ပါတယ်။ Cluster တက်လာပြီး ပထမ deploy အောင်မြင်ပါတယ်။ နောက် ခြောက်လအတွင်းမှာတော့ ingress controller၊ cluster autoscaler၊ DNS၊ certificate၊ metrics stack တွေကို တစ်ခုချင်း install လုပ်ရပြီး version တွေကို လိုက်ထိန်းရပါတယ်။

ပြီးတော့ Kubernetes version က standard support ကုန်ခါနီးလာလို့ upgrade လုပ်ရပါတယ် — deprecated API သုံးထားတဲ့ Helm chart နှစ်ခု ကျိုးသွားပါတယ်။ Feature အသစ်ရေးမယ့် အချိန်ရဲ့ သုံးပုံတစ်ပုံလောက်ကို platform ထိန်းဖို့ပဲ သုံးနေရပါတယ်။ အောက်က စာရင်းက သူတို့ ပိုင်လာတဲ့ အရာတွေပါ။

what-we-now-own.txt
cluster: demo (EKS)          owner: "whoever has time"
  - managed node group AMI updates          every few weeks
  - Kubernetes minor version upgrade        ~every 4 months upstream
  - add-ons: vpc-cni, coredns, kube-proxy   per upgrade
  - AWS Load Balancer Controller (Helm)     separate release cycle
  - cluster autoscaler / Karpenter          separate release cycle
  - external-dns, cert-manager              separate release cycles
  - Prometheus + Grafana                    storage, retention, upgrades
  - RBAC + access entries for 5 people      ad hoc
services actually shipped to customers:     3

ဘာကြောင့် ဒီလို ဖြစ်ရတာလဲ

EKS က control plane ကိုသာ manage လုပ်ပေးပါတယ်။ Cluster ကို production-ready ဖြစ်အောင် လုပ်တဲ့ add-on၊ controller နဲ့ upgrade စီမံမှု အများစုက ကိုယ့်တာဝန်ပါ။ ECS မှာတော့ ဒီအလုပ်တွေ အများစုကို AWS က service ထဲမှာ ထည့်ပေးထားလို့ team အသေးတွေအတွက် ကုန်ကျစရိတ် (အချိန်) ကွာခြားချက် ကြီးပါတယ်။

အဓိက သဘောတရား — EKS က ဘာကို ပိုင်ပြီး ခင်ဗျား ဘာကို ပိုင်လဲ

Control plane
Kubernetes ရဲ့ ဦးနှောက်ပါ — API server၊ cluster state အားလုံး သိမ်းတဲ့ etcd database၊ scheduler နဲ့ controller တွေ။ EKS မှာ AWS က multi-AZ ပေါ်မှာ run ပေး၊ patch လုပ်ပေး၊ backup လုပ်ပေးပါတယ်။

EKS cluster တစ်ခု ဖန်တီးလိုက်ရင် AWS က ကိုယ့် account ထဲ မဟုတ်ဘဲ AWS ဘက်က account ထဲမှာ control plane ကို run ပေးပါတယ်။ ကိုယ့် VPC ထဲကို ENI တွေနဲ့ ချိတ်ပြီး kubectl က API server endpoint ကို ခေါ်ပါတယ်။ etcd ပျက်သွားမှာ၊ API server scale မလုပ်နိုင်မှာ စိုးရိမ်စရာ မလိုပါဘူး — ဒါက EKS ရဲ့ အဓိက တန်ဖိုးပါ။

Data plane — pod တွေ တကယ် run တဲ့ compute — ကတော့ ဘယ် option ရွေးလဲပေါ် မူတည်ပြီး တာဝန် ပမာဏ ကွာပါတယ်။ ဒါ့အပြင် networking (VPC CNI)၊ DNS (CoreDNS)၊ kube-proxy လို add-on တွေ၊ load balancer controller၊ autoscaler၊ RBAC နဲ့ Kubernetes version upgrade တွေက ကိုယ့်လက်ထဲ ကျန်ပါတယ်။

text
EKS SHARED RESPONSIBILITY
-------------------------
+----------------- AWS-managed (AWS account) ------------------+
|  API server x N   etcd (multi-AZ)   scheduler   controllers |
+------------------------------+-------------------------------+
                               | ENIs in your VPC
+------------------------------v-------------------------------+
| YOUR account / VPC                                           |
|  add-ons: vpc-cni  coredns  kube-proxy  pod-identity-agent   |
|  controllers: LB controller, Karpenter, external-dns ...     |
|  +--------------+  +--------------+  +---------------------+  |
|  | managed node |  | Fargate      |  | Karpenter / Auto    |  |
|  | group (EC2)  |  | profile pods |  | Mode nodes (EC2)    |  |
|  +--------------+  +--------------+  +---------------------+  |
|  you: version upgrades, RBAC/access, IAM for pods, workloads |
+--------------------------------------------------------------+
Compute optionကိုယ်တိုင် ကိုင်ရတာ
Managed node groupInstance type ရွေး၊ AMI update ကို trigger လုပ်၊ autoscaler ထည့်
Fargate profilePod တစ်ခုစီ microVM တစ်ခု — DaemonSet၊ GPU၊ privileged pod မရ
KarpenterOpen-source controller ကို install/upgrade လုပ်၊ NodePool rule ရေး
EKS Auto ModeAWS က node lifecycle နဲ့ core add-on အချို့ ကိုင်ပေး၊ အပို management fee

Karpenter က pending ဖြစ်နေတဲ့ pod တွေကို ကြည့်ပြီး လိုတဲ့ size အတိအကျ instance ကို တိုက်ရိုက် launch လုပ်ပေးတဲ့ node autoscaler ပါ။ Node group အမျိုးမျိုး ကြိုမဖန်တီးထားရဘဲ Spot နဲ့ instance family အများကြီးကို ရောသုံးနိုင်ပြီး ဗလာဖြစ်နေတဲ့ node တွေကို စုစည်းပြီး ဖြုတ်ပေးလို့ cost ကို အများကြီး လျှော့နိုင်ပါတယ်။ EKS Auto Mode ကတော့ Karpenter ပေါ်မှာ အခြေခံထားပြီး node provisioning၊ OS patching နဲ့ အချို့ networking/storage capability တွေကို AWS က ကိုင်ပေးတဲ့ mode ပါ — ECS ရဲ့ 'ops နည်းတဲ့' အတွေ့အကြုံကို Kubernetes API နဲ့ ရချင်သူတွေအတွက်ပါ။ Auto Mode က ဘာတွေ ပါလဲဆိုတာ မကြာခဏ ပြောင်းနေလို့ docs မှာ နောက်ဆုံး အခြေအနေကို စစ်ပါ။

စိတ်ထဲမှာ ပုံဖော်ကြည့်ရန်
  1. AWS: control plane + etcd
  2. You: add-ons + controllers
  3. You: nodes (or Fargate/Auto)
  4. You: upgrades ~every 4 months
  5. You: IAM per pod, RBAC

EKS ကို 'managed Kubernetes API' လို့ မှတ်ပါ — 'managed platform' မဟုတ်ပါဘူး။ Platform ကို အပေါ်မှာ ကိုယ်တိုင် တည်ဆောက်ရပါတယ်။

eksctl ClusterConfig ပုံစံ

cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: demo
  region: us-east-1
  # version omitted on purpose: eksctl uses its current default
managedNodeGroups:
  - name: general
    instanceTypes: ["m7g.large", "m6g.large"]
    minSize: 2
    maxSize: 6
    desiredCapacity: 2
    privateNetworking: true
addons:
  - name: vpc-cni
  - name: coredns
  - name: kube-proxy
  - name: eks-pod-identity-agent
iam:
  podIdentityAssociations:
    - namespace: orders
      serviceAccountName: orders-sa
      permissionPolicyARNs:
        - arn:aws:iam::aws:policy/AmazonSQSReadOnlyAccess

eksctl က ဒီ file ကို CloudFormation stack တွေအဖြစ် ပြောင်းပြီး cluster၊ Graviton instance နှစ်မျိုးပါတဲ့ managed node group၊ core add-on လေးခုနဲ့ orders namespace ထဲက orders-sa service account အတွက် pod identity association ကို ဖန်တီးပေးပါတယ်။ 'eksctl create cluster -f cluster.yaml' နဲ့ run ပါ — ၁၅ မိနစ်ကနေ မိနစ် ၂၀ လောက် ကြာနိုင်ပါတယ်။

EKS cluster တစ်ခုရဲ့ day-2 စစ်ဆေးမှုနဲ့ pod identity

Cluster ဆောက်တာက ပထမနေ့ အလုပ်ပါ။ Platform ကို ပိုင်ဆိုင်တယ်ဆိုတာ ဒီလို စစ်ဆေးမှုတွေကို ပုံမှန် လုပ်နေရတာပါ — ဘယ် version မှာ ရှိလဲ၊ add-on တွေ ဘယ် version လဲ၊ upgrade မလုပ်ခင် compatible version ဘာလဲ။ နောက်ဆုံးမှာ orders service ရဲ့ pod တွေကို SQS ဖတ်ခွင့် ပေးဖို့ pod identity association တစ်ခု ထည့်ပါတယ်။

day2-checks.sh
CLUSTER=demo
aws eks update-kubeconfig --name $CLUSTER --region us-east-1

K8S_VERSION=$(aws eks describe-cluster --name $CLUSTER \
  --query 'cluster.version' --output text)
echo "control plane: $K8S_VERSION"

aws eks list-nodegroups --cluster-name $CLUSTER
aws eks list-addons --cluster-name $CLUSTER

# newest vpc-cni build that supports our Kubernetes version
aws eks describe-addon-versions --kubernetes-version $K8S_VERSION \
  --addon-name vpc-cni \
  --query 'addons[0].addonVersions[0].addonVersion' --output text

ROLE_ARN=arn:aws:iam::111122223333:role/orders-sqs-reader
aws eks create-pod-identity-association --cluster-name $CLUSTER \
  --namespace orders --service-account orders-sa --role-arn $ROLE_ARN
aws eks list-pod-identity-associations --cluster-name $CLUSTER --namespace orders

kubectl get nodes -L node.kubernetes.io/instance-type

Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်

  1. update-kubeconfigaws eks update-kubeconfig --name $CLUSTER

    ~/.kube/config ထဲမှာ cluster entry ကို ထည့်ပြီး kubectl က IAM identity နဲ့ authenticate လုပ်အောင် ပြင်ပေးပါတယ်။ Cluster ထဲ ဝင်ခွင့်ကိုတော့ access entry (သို့မဟုတ် cluster အဟောင်းတွေမှာ aws-auth ConfigMap) က ဆုံးဖြတ်ပါတယ်။

  2. describe-cluster--query 'cluster.version'

    Control plane ရဲ့ Kubernetes minor version ကို ယူပါတယ်။ ဒီ version ရဲ့ standard support ဘယ်တော့ ကုန်မလဲဆိုတာကို calendar မှာ မှတ်ထားသင့်ပါတယ်။

  3. list-addons / describe-addon-versions--kubernetes-version $K8S_VERSION --addon-name vpc-cni

    Add-on တိုင်းမှာ Kubernetes version တစ်ခုချင်းအလိုက် compatible version စာရင်း ရှိပါတယ်။ Control plane upgrade မလုပ်ခင်နဲ့ လုပ်ပြီးနောက် add-on တွေကို ကိုက်ညီအောင် update လုပ်ရပါတယ်။

  4. create-pod-identity-association--namespace orders --service-account orders-sa --role-arn $ROLE_ARN

    orders namespace ထဲက orders-sa service account ကို သုံးတဲ့ pod တွေက ဒီ IAM role ရဲ့ temporary credential ကို ရပါမယ်။ Node အားလုံးရဲ့ instance role ကို permission ချဲ့စရာ မလိုပါဘူး။

  5. kubectl get nodes-L node.kubernetes.io/instance-type

    Node တစ်ခုစီရဲ့ instance type ကို column အဖြစ် ပြပါတယ် — Karpenter သုံးရင် instance type မျိုးစုံ ရောနေတာကို ဒီမှာ မြင်ရပါမယ်။

You should see
Sample output (version နဲ့ ID တွေ ကွာနိုင်ပါတယ်):
control plane: 1.33
{"nodegroups": ["general"]}
{"addons": ["coredns", "eks-pod-identity-agent", "kube-proxy", "vpc-cni"]}
v1.19.5-eksbuild.1
{"associations": [{"namespace": "orders", "serviceAccount": "orders-sa", ...}]}

Pod တွေကို IAM permission ပေးခြင်း — IRSA နဲ့ EKS Pod Identity

Pod တွေက node ရဲ့ instance role ကို သုံးမိရင် node ပေါ်က pod အားလုံး permission တူတူ ရသွားပါတယ် — ECS မှာ task role မထားသလို ပြဿနာပါ။ EKS မှာ pod တစ်ခုချင်း (service account တစ်ခုချင်း) အလိုက် role ပေးနည်း နှစ်မျိုး ရှိပါတယ်။

IRSA (IAM Roles for Service Accounts) က cluster တစ်ခုစီရဲ့ OIDC issuer ကို IAM identity provider အဖြစ် register လုပ်ပြီး role trust policy ထဲမှာ cluster ရဲ့ OIDC URL နဲ့ service account နာမည်ကို ရေးရပါတယ်။ Service account မှာ eks.amazonaws.com/role-arn annotation ထည့်ရပါတယ်။ Cluster အသစ် တစ်ခု ထပ်ဆောက်တိုင်း trust policy တွေ လိုက်ပြင်ရတာက အဓိက အခက်အခဲပါ။

EKS Pod Identity က ပိုရိုးရှင်းပါတယ်။ Role trust policy က pods.eks.amazonaws.com ကို တစ်ခါတည်း ယုံကြည်ပြီး ဘယ် cluster/namespace/service account နဲ့ ချိတ်မလဲကို EKS API ရဲ့ association အဖြစ် သိမ်းပါတယ်။ OIDC provider မလိုပဲ role တစ်ခုကို cluster အများကြီးမှာ ပြန်သုံးနိုင်ပါတယ်။ eks-pod-identity-agent add-on လိုပြီး Fargate pod တွေမှာ မရသေးလို့ အဲဒီ pod တွေအတွက် IRSA ကို ဆက်သုံးရပါတယ်။

pod-identity-role.sh
cat > pod-identity-trust.json <<'EOF'
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "Service": "pods.eks.amazonaws.com" },
      "Action": ["sts:AssumeRole", "sts:TagSession"]
    }
  ]
}
EOF
aws iam create-role --role-name orders-sqs-reader \
  --assume-role-policy-document file://pod-identity-trust.json
aws iam attach-role-policy --role-name orders-sqs-reader \
  --policy-arn arn:aws:iam::aws:policy/AmazonSQSReadOnlyAccess
aws eks create-addon --cluster-name demo --addon-name eks-pod-identity-agent
orders.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: orders-sa
  namespace: orders
  # IRSA only: with EKS Pod Identity this annotation is not needed
  # annotations:
  #   eks.amazonaws.com/role-arn: arn:aws:iam::111122223333:role/orders-sqs-reader
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: orders-worker
  namespace: orders
spec:
  replicas: 2
  selector:
    matchLabels: { app: orders-worker }
  template:
    metadata:
      labels: { app: orders-worker }
    spec:
      serviceAccountName: orders-sa
      containers:
        - name: worker
          image: 111122223333.dkr.ecr.us-east-1.amazonaws.com/orders-worker:2.1.0
          resources:
            requests: { cpu: 250m, memory: 256Mi }

Upgrade cadence နဲ့ operational load

Upstream Kubernetes က minor version အသစ်ကို တစ်နှစ် သုံးကြိမ်လောက် ထုတ်ပါတယ်။ EKS မှာ version တစ်ခုစီက standard support ၁၄ လ ရပြီး ပြီးရင် extended support ၁၂ လ ထပ်ရပါတယ် — ဒါပေမဲ့ extended support ကာလမှာ cluster ရဲ့ နာရီအလိုက် ဈေးက standard ထက် အဆများစွာ မြင့်ပါတယ်။ ဆိုလိုတာက cluster တစ်ခုကို တစ်နှစ်မှာ အနည်းဆုံး တစ်ကြိမ်၊ ပုံမှန်ဆို နှစ်ကြိမ်လောက် upgrade လုပ်ရပါတယ်။

Upgrade က minor version တစ်ဆင့်ချင်းသာ လုပ်လို့ရပြီး ပြန်ဆင်းလို့ မရပါဘူး။ ပုံမှန် အစီအစဉ်ကတော့ deprecated API တွေကို စစ် (EKS upgrade insights က ကူညီပါတယ်)၊ control plane ကို upgrade၊ add-on တွေကို update၊ ပြီးမှ node တွေကို rolling replace လုပ်တာပါ။ Cluster ၁၀ ခု ရှိတဲ့ organization မှာ ဒါက အမြဲ လည်ပတ်နေတဲ့ အလုပ်တစ်ခု ဖြစ်လာပါတယ်။ ECS မှာ ဒီလို version upgrade မရှိပါဘူး။

၁. Deprecated API စစ်

Upgrade insights နဲ့ manifest/Helm chart တွေမှာ ဖြုတ်ခံရမယ့် API version သုံးထားလား စစ်ပါ။

၂. Control plane upgrade

Minor version တစ်ဆင့်တည်း တက်ပါ။ API server က rolling ပြောင်းလို့ downtime မရှိပေမဲ့ ပြန်ဆင်းလို့ မရပါ။

၃. Add-on update

vpc-cni၊ coredns၊ kube-proxy နဲ့ ကိုယ်တိုင် install လုပ်ထားတဲ့ controller တွေကို compatible version ဆီ တင်ပါ။

၄. Node rolling replace

Managed node group update သို့မဟုတ် Karpenter drift နဲ့ node အသစ်တွေ အစားထိုးပါ။ PodDisruptionBudget တွေ မှန်ကန်ဖို့ လိုပါတယ်။

ကုန်ကျစရိတ် ဖြစ်စေတဲ့ အချက်များနဲ့ ဆုံးဖြတ်ချက် လမ်းညွှန်

EKS မှာ cluster တစ်ခုစီအတွက် control plane ကို နာရီအလိုက် ပုံသေ ကြေး ပေးရပါတယ် (standard support မှာ us-east-1 တွင် တစ်နာရီ ဒေါ်လာ 0.10 ခန့်၊ လစဉ် ဒေါ်လာ ၇၀ ကျော်ခန့် — pricing page မှာ စစ်ပါ)။ ECS control plane က အခမဲ့ပါ။ Compute ဘက်မှာတော့ နှစ်ခုလုံး EC2 သို့မဟုတ် Fargate ဈေးတူတူ ပေးရပါတယ်။

တကယ့် ကွာခြားချက်က ကိုယ်တိုင် run ရတဲ့ အရာတွေမှာ ရှိပါတယ် — monitoring stack၊ controller တွေအတွက် node capacity၊ cluster တစ်ခုစီရဲ့ ကြေး၊ အထူးသဖြင့် engineer အချိန်။ Environment တစ်ခုစီ (dev, staging, prod) ကို cluster သီးသန့် ခွဲရင် ဒီကုန်ကျစရိတ်တွေ အဆမြှောက် တက်ပါတယ်။ ဆန့်ကျင်ဘက်အနေနဲ့ workload အရမ်းများတဲ့ team ကြီးတွေမှာ Karpenter ရဲ့ bin-packing နဲ့ Spot သုံးမှုက compute ကို သိသိသာသာ သက်သာစေနိုင်ပါတယ်။

ရွေးချယ်မှုသင့်တော်တဲ့ အခြေအနေ
LambdaEvent-driven၊ load တက်ကျ များ၊ request တစ်ခု ၁၅ မိနစ်အောက်၊ idle ဖြစ်ရင် ဘာမှ မပေးချင်
ECS (Fargate)Long-running container၊ AWS ပေါ်မှာပဲ၊ platform team မရှိ သို့မဟုတ် သေး
EKSKubernetes ကျွမ်းကျင်မှု/tool ရှိပြီးသား၊ multi-cloud၊ operator/Helm ecosystem လို၊ platform team ရှိ
text
PLATFORM DECISION TREE
----------------------
            short, event-driven, spiky?
               |                    |
              yes                   no
               v                    v
            Lambda      already run Kubernetes, or need
                        its ecosystem / portability?
                           |                  |
                          yes                 no
                           v                  v
              have people to run it?        ECS on Fargate
                 |              |
                yes             no
                 v              v
          EKS (+Karpenter)   EKS Auto Mode, or reconsider ECS

Production မှာ

Production မှာ တကယ် ဘယ်လို သုံးကြလဲ

EKS ကို အောင်မြင်စွာ သုံးနေတဲ့ organization တွေမှာ ပုံစံ တူတာ တစ်ခု ရှိပါတယ် — platform team သီးသန့် ရှိပြီး application team တွေအတွက် 'golden path' တစ်ခု ပေးထားပါတယ်။ Application team တွေက Helm chart သို့မဟုတ် Kustomize overlay ကို Git ထဲ push ရုံပါပဲ၊ Argo CD သို့မဟုတ် Flux လို GitOps tool က cluster ထဲ sync လုပ်ပေးပါတယ်။ Cluster အရေအတွက်ကိုလည်း နည်းနိုင်သမျှ နည်းအောင် ထားပြီး namespace နဲ့ RBAC နဲ့ team တွေကို ခွဲကြပါတယ်။

ECS ကို ရွေးတဲ့ team တွေကတော့ platform ကို CDK construct library တစ်ခုအဖြစ် ထုပ်ပြီး ဝေမျှကြပါတယ်။ Organization အကြီးတွေမှာ နှစ်ခုလုံး ရောသုံးတာ မဆန်းပါဘူး — data/ML platform က Kubernetes operator တွေ လိုလို့ EKS မှာ၊ ရိုးရိုး web service တွေက ECS မှာ၊ event glue တွေက Lambda မှာ။ အရေးကြီးတာက ရွေးချယ်မှု တစ်ခုချင်းရဲ့ ops ကုန်ကျစရိတ်ကို ရှင်းရှင်းလင်းလင်း သိပြီး ရွေးတာပါ။

Network planning ကို စောစော လုပ်ပါ

Amazon VPC CNI က pod တိုင်းကို VPC IP တစ်ခုစီ ပေးလို့ /24 subnet လို အသေးစား subnet တွေ အမြန် ကုန်သွားတတ်ပါတယ်။ Cluster ဆောက်ခင်မှာ ကြီးတဲ့ subnet (သို့မဟုတ် secondary CIDR) နဲ့ prefix delegation ကို စီစဉ်ထားပါ။

အမှားများ

အဖြစ်များတဲ့ အမှားတွေ

အမှား ၁ — Node instance role ကို permission အကုန် ပေးခြင်း

Pod တစ်ခုက S3 ကို ဖတ်ဖို့ လိုတဲ့အခါ အလွယ်ဆုံးနည်းက node instance role ထဲ s3:* ထည့်တာပါ။ ဒါပေမဲ့ အဲဒီ node ပေါ်ရောက်တဲ့ pod တိုင်း — third-party Helm chart တွေအပါအဝင် — က အဲဒီ permission ရသွားပါတယ်။ Pod Identity သို့မဟုတ် IRSA သုံးပြီး service account တစ်ခုချင်းအလိုက် role ပေးပါ၊ ပြီးရင် pod တွေကနေ instance metadata ရောက်တာကို ကန့်သတ်ပါ (IMDSv2 hop limit 1)။

အမှား ၂ — Upgrade ကို extended support ရောက်မှ စဉ်းစားခြင်း

Version upgrade ကို 'အချိန်ရရင် လုပ်မယ်' လို့ ထားလိုက်ရင် cluster က extended support ထဲ ရောက်ပြီး control plane ဈေး အဆများစွာ တက်သွားပါတယ်။ ပြီးတော့ version နှစ်ဆင့် သုံးဆင့် နောက်ကျနေလို့ upgrade တစ်ခါမှာ deprecated API အများကြီးနဲ့ add-on အားလုံးကို တပြိုင်နက် ကိုင်တွယ်ရပါတယ်။ Upgrade ကို quarter တိုင်း သတ်မှတ်ထားတဲ့ အလုပ်အဖြစ် စီစဉ်ပါ။

အမှား ၃ — 'Resume မှာ ကောင်းလို့' EKS ကို ရွေးခြင်း

Service နည်းနည်းပဲ ရှိပြီး platform engineer မရှိတဲ့ team က Kubernetes ကို ရွေးတာက ပြဿနာ အပိုင်းမှာ မြင်ခဲ့တဲ့အတိုင်း feature အချိန်ကို စားပါတယ်။ Kubernetes ecosystem ကနေ ဘာ feature ကို တကယ် လိုလဲ ရေးချကြည့်ပါ — စာရင်း ဗလာဖြစ်နေရင် ECS သို့မဟုတ် Lambda က ပိုသင့်တော်ပါတယ်။

Best Practices

အကောင်းဆုံး လုပ်ထုံးလုပ်နည်းများ

  • Cluster အရေအတွက်ကို နည်းအောင်ထားပြီး namespace၊ RBAC၊ ResourceQuota နဲ့ team တွေကို ခွဲပါ။
  • Add-on တွေကို EKS managed add-on အဖြစ် သုံးနိုင်သမျှ သုံးပါ — version compatibility ကို AWS က စစ်ပေးပါတယ်။
  • Cluster အသစ်တွေမှာ aws-auth ConfigMap အစား access entry တွေကို သုံးပါ။
  • Cluster configuration အားလုံးကို eksctl/CDK/Terraform နဲ့ code အဖြစ် ထားပြီး upgrade ကို staging cluster မှာ အရင် စမ်းပါ။

💰 Cost & Cleanup

EKS မှာ free tier မရှိပါဘူး။ Cluster ဖန်တီးလိုက်တာနဲ့ control plane ကြေး (standard support မှာ တစ်နာရီ ဒေါ်လာ 0.10 ခန့်) စတင် ကျပြီး managed node group ရဲ့ EC2 instance တွေ၊ NAT Gateway၊ EBS volume တွေလည်း နာရီအလိုက် ကျပါတယ်။ eksctl က CloudFormation stack အများကြီး ဖန်တီးလို့ console ကနေ တစ်ခုချင်း ဖျက်မနေဘဲ အောက်က command နဲ့ ဖျက်ပါ။ Lab ပြီးတာနဲ့ ချက်ချင်း ဖျက်ပါ — ဈေးနှုန်း အတိအကျကို pricing page မှာ စစ်ပါ။

စမ်းပြီးရင် ဖျက်ဖို့ command

cleanup.sh
ASSOC_ID=$(aws eks list-pod-identity-associations --cluster-name demo \
  --namespace orders --query 'associations[0].associationId' --output text)
aws eks delete-pod-identity-association --cluster-name demo --association-id $ASSOC_ID
eksctl delete cluster --name demo --region us-east-1 --wait
aws iam detach-role-policy --role-name orders-sqs-reader \
  --policy-arn arn:aws:iam::aws:policy/AmazonSQSReadOnlyAccess
aws iam delete-role --role-name orders-sqs-reader

Mini challenge

Mini challenge — platform ဆုံးဖြတ်ချက် မှတ်တမ်း

Company တစ်ခုမှာ workload သုံးခု ရှိပါတယ် — (A) တစ်ရက်ကို အကြိမ် ၂၀၀ လောက် upload ဖြစ်တဲ့ image thumbnail ထုတ်ပေးတဲ့ job၊ (B) 24 နာရီ run နေရတဲ့ REST API ၄ ခု (developer ၆ ယောက်၊ platform engineer မရှိ)၊ (C) Kubernetes operator တွေ (Spark, Kafka operator) သုံးဖို့ လိုတဲ့ data platform (platform engineer ၃ ယောက် ရှိ)။ Workload တစ်ခုစီအတွက် platform ရွေးပြီး အကြောင်းပြချက် ရေးပါ။

  • Workload တစ်ခုစီအတွက် Lambda၊ ECS သို့မဟုတ် EKS တစ်ခု ရွေးပါ
  • Ops ကုန်ကျစရိတ်နဲ့ compute ကုန်ကျစရိတ် နှစ်ခုလုံးကို ထည့်စဉ်းစားပါ
  • ဘယ်အခြေအနေ ပြောင်းရင် ဆုံးဖြတ်ချက် ပြန်ပြင်ရမလဲ တစ်ကြောင်းစီ ရေးပါ

ရလဒ်: A = Lambda၊ B = ECS on Fargate၊ C = EKS ဆိုတဲ့ အဖြေမျိုး ဖြစ်ပြီး တစ်ခုစီမှာ ops နဲ့ cost အကြောင်းပြချက် ပါရပါမယ်။

အရိပ်အမြွက် ကြည့်ရန်

Decision tree ကို အပေါ်ကနေ စပြီး မေးခွန်းတစ်ခုချင်း ဖြေကြည့်ပါ — 'ဒီ team မှာ Kubernetes ကို run နိုင်တဲ့ လူ ရှိလား' ဆိုတဲ့ မေးခွန်းက အရေးကြီးဆုံးပါ။

အဖြေ ကြည့်ရန်
platform-decision.md
A thumbnails  -> Lambda (S3 event trigger)
  why: ~200 short jobs/day; idle the rest of the time; no servers or
       cluster fee; per-invocation pricing is close to zero at this volume
  revisit if: jobs exceed 15 minutes or need a GPU -> ECS/Batch task

B REST APIs   -> ECS on Fargate behind one ALB
  why: always-on containers; no platform engineer to own upgrades,
       add-ons or node patching; free control plane; CDK construct
       library shared across the 4 services
  revisit if: the org adopts Kubernetes elsewhere and gains a platform team

C data platf. -> EKS (managed node groups or Karpenter, Spot for executors)
  why: Spark/Kafka operators exist only for Kubernetes; 3 platform
       engineers can own upgrades; Karpenter bin-packing + Spot cuts
       compute cost for bursty Spark jobs
  revisit if: a managed service (EMR Serverless, MSK) covers the need

Quick Quiz 1 / 3

EKS cluster မှာ AWS က အပြည့်အဝ manage လုပ်ပေးတာ ဘယ်ဟာလဲ?

Quick Quiz 2 / 3

Cluster ၁၂ ခုမှာ role တစ်ခုတည်းကို pod တွေကို ပေးချင်ပြီး cluster အသစ် ထပ်တိုင်း trust policy မပြင်ချင်ပါဘူး။ ဘာကို သုံးသင့်လဲ?

Quick Quiz 3 / 3

EKS Fargate profile ပေါ်မှာ run လို့ မရတာ ဘာလဲ?

မှတ်ထားရမယ့် အချက်များ

  • EKS = managed control plane; add-on၊ controller၊ upgrade နဲ့ workload IAM က ကိုယ့်တာဝန်။
  • Compute: managed node group၊ Fargate profile၊ Karpenter၊ Auto Mode — ops ဝန် အနည်းအများ ကွာပါတယ်။
  • Pod IAM အတွက် EKS Pod Identity (ရိုးရှင်း၊ cluster ကျော် ပြန်သုံးရ) သို့မဟုတ် IRSA (Fargate pod တွေအတွက်)။
  • Version တစ်ခုချင်း standard support ၁၄ လ — upgrade ကို ပုံမှန် အလုပ်အဖြစ် စီစဉ်ပါ။
  • Lambda → ECS → EKS ကို workload နဲ့ team ရဲ့ ops စွမ်းရည်ပေါ် မူတည်ပြီး ရွေးပါ။

Amazon EKS User Guide — AWS Documentation

EKS Pod Identity — AWS Documentation

Amazon EKS Best Practices Guide — AWS Documentation

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

EKS နဲ့ ECS — ဘယ်အချိန် Kubernetes ကို ရွေးသင့်လဲ | Thuta Learning