EKS ALB vs NLB
釐清 K8s Service 類型、Ingress 與 Ingress Controller 的差異,以及 AWS Load Balancer Controller 何時建立 ALB 或 NLB。
## 問題:EKS 前面掛 ALB 或 NLB 具體而言的影響是什麼?
釐清不同 service 之間的用途
- Cluster IP:可以讓 cluster 內部互聯的 service
- Load Balancer:可以讓 cluster 外部放問的 service
- ExternalName:外部服務的別名,讓 cluster 裡面的 workload 可以用 service 的 dns 連線到外部服務
- NodePort(不常見可忽略)
Service 如何解決 pod ip 變動的問題?
- 是 control plante 中的 etcd 在記錄 endpoint 對到哪個 pod
- kube-proxy 透過 api server 拿到 endpoint 更新
- 在 nodes 裡面更新新的 endpoint 規則到 iptables
釐清 ingress & ingress controller 之間的差異
- ingress:指定流量應該要導向哪個 service 的規則,基本上是根據 host / path / prefix (L7) … 判斷
- ingress controller:實作 ingress 導流的物件,常見的 ingress controller 都是 L7 的
那有 L4 的 ingress controller 嗎?
- Kubernetes 的 ingress 主要是為了 L7 流量設置的,所以沒有這種東西
- 如果要自行處理 L4 流量的話,需要額外安裝 traefik 等自訂的 CRD 來控制
Load Balancer Controller 核心用途
- It satisfies Kubernetes Ingress resources by provisioning Application Load Balancers. → 幫 ingress 長出 ALB
- 建出 ALB 的前提:
- 沒有部署 load balancer service
- Ingress Class 指向 ALB
- 此時的 ingress controller 為 ALB(更精確是 Load Balancer Controller pod)
- 好處:AWS 管理 ingress controller,不需要額外多做設定
- 建出 ALB 的前提:
- It satisfies Kubernetes Service resources by provisioning Network Load Balancers. → 幫 service (Load Balancer) 長出 NLB
- 此時的 ingress controller 是 load balancer service 所掛載的 nginx
- 好處:自管 ingress controller,可高度客製化規則