当我在 Amazon Elastic Kubernetes Service (Amazon EKS) 的 Amazon Linux 2023 AMI 中使用自定义脚本、自管理节点或自定义启动模板时,我想提供自定义用户数据。
简短描述
Amazon Linux 2023 使用采用 YAML 配置架构的 nodeadm 节点初始化流程。有关详细信息,请参阅 Amazon EKS-optimized Amazon Linux 2023 AMIs now available 中的升级到 AL2023 之前部分。
解决方法
按以下格式向用户数据添加所需的最低参数:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"
--//
Content-Type: application/node.eks.aws
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
apiServerEndpoint: https://example.com
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
name: my-cluster
--//--
按以下格式修改 kubelet 或容器组件:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="
--==MYBOUNDARY==
Content-Type: application/node.eks.aws
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
name: my-cluster
apiServerEndpoint: https://example.com
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
kubelet:
config:
maxPods: 17
clusterDNS:
- 10.100.0.10
flags:
- "--node-labels=eks.amazonaws.com/nodegroup-image=ami-0cc04929616d2c6ba,eks.amazonaws.com/capacityType=ON_DEMAND,eks.amazonaws.com/nodegroup=al23"
containerd: {}
instance:
localStorage: {}
--==MYBOUNDARY==--
按以下格式传递自定义脚本或命令:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"
--//
Content-Type: application/node.eks.aws
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
name: my-cluster
apiServerEndpoint: https://example.com
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
--//
Content-Type: text/x-shellscript; charset="us-ascii"
#!/bin/bash
echo "Hello AL2023!"
--//
相关信息
Amazon EKS AMI API 参考