Auto Scaling - Eksctl 使用者指南

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Auto Scaling

啟用 Auto Scaling

您可以使用 IAM 角色建立叢集 (或現有叢集中的節點群組),以允許使用叢集自動擴展器

eksctl create cluster --asg-access

此旗標也會設定 k8s.io/cluster-autoscaler/enabledk8s.io/cluster-autoscaler/<clusterName> 標籤,因此節點群組探索應該可以運作。

叢集執行後,您將需要安裝 Cluster Autoscaler 本身。

您也應該將下列項目新增至受管或未受管節點群組定義 (Cluster Autoscaler),以新增擴展節點群組所需的標籤:

nodeGroups: - name: ng1-public iam: withAddonPolicies: autoScaler: true

從 0 向上擴展

如果您想要從 0 擴展節點群組,並在節點群組上定義了標籤和/或污點,則需要將這些標籤傳播為 Auto Scaling 群組 (ASGs) 上的標籤。

其中一種方法是在節點群組定義的 tags 欄位中設定 ASG 標籤。例如,指定具有下列標籤和污點的節點群組:

nodeGroups: - name: ng1-public ... labels: my-cool-label: pizza taints: key: feaster value: "true" effect: NoSchedule

您需要新增下列 ASG 標籤:

nodeGroups: - name: ng1-public ... labels: my-cool-label: pizza taints: feaster: "true:NoSchedule" tags: k8s.io/cluster-autoscaler/node-template/label/my-cool-label: pizza k8s.io/cluster-autoscaler/node-template/taint/feaster: "true:NoSchedule"

對於受管和非受管節點群組,這可以透過將 propagateASGTags設定為 來自動完成true,這會將標籤和污點作為標籤新增至 Auto Scaling 群組:

nodeGroups: - name: ng1-public ... labels: my-cool-label: pizza taints: feaster: "true:NoSchedule" propagateASGTags: true

區域感知 Auto Scaling

如果您的工作負載是區域特定的,您將需要為每個區域建立單獨的節點群組。這是因為 cluster-autoscaler 假設群組中的所有節點完全相同。因此,例如,如果擴展事件是由需要區域特定 PVC (例如 EBS 磁碟區) 的 Pod 觸發,則新節點可能會排程在錯誤的可用區域中,且 Pod 將無法啟動。

如果您的環境符合下列條件,則每個可用區域不需要個別的節點群組:

  • 沒有區域特定的儲存需求。

  • 與主機以外的拓撲不需要 podAffinity。

  • 區域標籤上不需要 nodeAffinity。

  • 區域標籤上沒有 nodeSelector。

(在此處此處閱讀更多資訊。)

如果您符合上述所有要求 (可能也符合其他要求),您應該使用跨越多個AZs單一節點群組來確保安全。否則,您會想要建立個別的單一可用區域節點群組:

之前:

nodeGroups: - name: ng1-public instanceType: m5.xlarge # availabilityZones: ["eu-west-2a", "eu-west-2b"]

之後:

nodeGroups: - name: ng1-public-2a instanceType: m5.xlarge availabilityZones: ["eu-west-2a"] - name: ng1-public-2b instanceType: m5.xlarge availabilityZones: ["eu-west-2b"]