View a markdown version of this page

自定义 AMI 支持 - Eksctl 用户指南

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

自定义 AMI 支持

设置节点 AMI ID

--node-ami标志支持许多高级用例,例如使用自定义 AMI 或实时查询 AWS 以确定要使用哪个 AMI。该标志可用于非 GPU 和 GPU 图像。

该标志可以采用 AMI 图像 ID 以供图像明确使用。它还可以采用以下 “特殊” 关键字:

Keyword 说明

自动

表示应通过查询 AWS EC2 来找到用于节点的 AMI。这与自动解析器有关。

自动发短信

表示应通过查询 AWS SSM 参数存储来找到用于节点的 AMI。

注意

目前,EKS 托管节点组在使用自定义 AMI 时仅支持以下 AMI 系列:AmazonLinux2023、、、AmazonLinux2Bottlerocket、和 Ubuntu2004 UbuntuPro2004 Ubuntu2204 Ubuntu2404

设置--node-ami为 ID 字符串时,eksctl将假定已请求自定义 AMI。对于 EKS 管理和自行管理的 AmazonLinux 2 和 Ubuntu 节点,这意味着overrideBootstrapCommand这是必需的。 AmazonLinux2023 年,在使用自定义 AMI overrideBootstrapCommand 时可以省略,因为 eksctl 会自动生成所需的最小值。 NodeConfig有关节点引导的更多信息,请参见节点引导。 GitHub

CLI 标志示例:

eksctl create cluster --node-ami=auto # with a custom ami id eksctl create cluster --node-ami=ami-custom1234

配置文件示例:

nodeGroups: - name: ng1 instanceType: p2.xlarge amiFamily: AmazonLinux2 ami: auto - name: ng2 instanceType: m5.large amiFamily: AmazonLinux2 ami: ami-custom1234 managedNodeGroups: - name: m-ng-2 amiFamily: AmazonLinux2 ami: ami-custom1234 instanceType: m5.large overrideBootstrapCommand: | #!/bin/bash /etc/eks/bootstrap.sh <cluster-name>

--node-ami标志也可以与一起使用eksctl create nodegroup

设置节点 AMI 系列

--node-ami-family可以采用以下关键字:

Keyword 说明

AmazonLinux2

表示应使用基于亚马逊 Linux 2 的 EKS AMI 映像(默认)。

AmazonLinux2023

表示应使用基于亚马逊 Linux 2023 的 EKS AMI 映像。

Ubuntu2004

表示应使用基于 Ubuntu 20.04 LTS (Focal) 的 EKS AMI 镜像(支持 EKS 1.29)。

UbuntuPro2004

表示应使用基于 Ubuntu Pro 20.04 LTS (Focal) 的 EKS AMI 镜像(适用于 EKS >= 1.27,1.29)。

Ubuntu2204

表示应使用基于 Ubuntu 22.04 LTS (Jammy) 的 EKS AMI 映像(适用于 EKS >= 1.29)。

UbuntuPro2204

表示应使用基于 Ubuntu Pro 22.04 LTS (Jammy) 的 EKS AMI 映像(适用于 EKS >= 1.29)。

Ubuntu2404

表示应使用基于 Ubuntu 24.04 LTS (Noble) 的 EKS AMI 镜像(适用于 EKS >= 1.31)。

UbuntuPro2404

表示应使用基于 Ubuntu Pro 24.04 LTS(Noble)的 EKS AMI 镜像(适用于 EKS >= 1.31)。

Bottlerocket

表示应使用基于 Bottlerocket 的 EKS AMI 映像。

WindowsServer2019FullContainer

表示应使用基于 Windows Server 2019 完整容器的 EKS AMI 映像。

WindowsServer2019CoreContainer

表示应使用基于 Windows Server 2019 核心容器的 EKS AMI 镜像。

WindowsServer2022FullContainer

表示应使用基于 Windows Server 2022 完整容器的 EKS AMI 镜像。

WindowsServer2022CoreContainer

表示应使用基于 Windows Server 2022 Core Container 的 EKS AMI 镜像。

CLI 标志示例:

eksctl create cluster --node-ami-family=AmazonLinux2

配置文件示例:

nodeGroups: - name: ng1 instanceType: m5.large amiFamily: AmazonLinux2 managedNodeGroups: - name: m-ng-2 instanceType: m5.large amiFamily: Ubuntu2204

--node-ami-family标志也可以与一起使用eksctl create nodegroupeksctl要求在使用自定义 AMI 时通过配置文件或 --node-ami-family CLI 标志明确设置 AMI 系列。

注意

目前,EKS 托管节点组在使用自定义 AMI 时仅支持以下 AMI 系列:AmazonLinux2023、、、AmazonLinux2Bottlerocket、和 Ubuntu2004 UbuntuPro2004 Ubuntu2204 Ubuntu2404

Windows 自定义 AMI 支持

只有自我管理的 Windows 节点组才能指定自定义 AMI。amiFamily应设置为有效的 Windows AMI 系列。

以下 PowerShell 变量将可用于引导脚本:

$EKSBootstrapScriptFile
$EKSClusterName
$APIServerEndpoint
$Base64ClusterCA
$ServiceCIDR
$KubeletExtraArgs
$KubeletExtraArgsMap: A hashtable containing arguments for the kubelet, e.g., @{ 'node-labels' = ''; 'register-with-taints' = ''; 'max-pods' = '10'}
$DNSClusterIP
$ContainerRuntime

配置文件示例:

nodeGroups: - name: custom-windows amiFamily: WindowsServer2022FullContainer ami: ami-01579b74557facaf7 overrideBootstrapCommand: | & $EKSBootstrapScriptFile -EKSClusterName "$EKSClusterName" -APIServerEndpoint "$APIServerEndpoint" -Base64ClusterCA "$Base64ClusterCA" -ContainerRuntime "containerd" -KubeletExtraArgs "$KubeletExtraArgs" 3>&1 4>&1 5>&1 6>&1

Bottlerocket 自定义 AMI 支持

对于 BottleRocket 节点,overrideBootstrapCommand不支持。相反,要指定自己的引导容器,应使用该bottlerocket字段作为配置文件的一部分。 E.g。

nodeGroups: - name: bottlerocket-ng ami: ami-custom1234 amiFamily: Bottlerocket bottlerocket: enableAdminContainer: true settings: bootstrap-containers: bootstrap: source: <MY-CONTAINER-URI>