如何使用 eksctl 为 Amazon EKS 节点创建多个节点组?
我想使用 eksctl 为 Amazon Elastic Kubernetes Service (Amazon EKS) 节点创建多个节点组。
简短描述
您可以使用 eksctl 和默认参数创建节点组。或者,使用自定义参数创建一个节点组,并为多个节点组创建一个配置文件。
要安装最新版本的 eksctl,请参阅 eksctl 网站上的安装。
要确认终端上已配置並安装 eksctl 且具有正确的权限,请运行以下命令:
$ eksctl version
然后,根据要使用的参数类型选择以下分辨率之一。
解决方法
使用默认参数创建节点组
-
要使用默认参数再创建一個节点组,请运行以下命令:
$ eksctl create nodegroup --cluster=yourClusterName --name=yourNodeGroupName --region yourRegionName
-
以下是默认参数:
Instance type = m5.largeAMI : lastest AWS EKS AMI Nodes-desired capacity = 2 Nodes-min capacity =2 Nodes-max capacity=2
注意:默认情况下,新节点组从控制面板继承 Kubernetes 的版本 (–version=auto)。您可以指定不同版本的 Kubernetes(例如,version=1.27)。要使用最新版本的 Kubernetes,请运行 –version=latest 命令。
-
要确认新节点组已附加到集群并验证节点是否已加入集群,请运行以下命令:
$ kubectl get nodes $ eksctl get nodegroups --cluster yourClusterName --region yourRegionName
在输出中,确认节点的状态为 READY 且节点组状态为 ACTIVE。例如:
节点组状态
$ eksctl get nodegroups --cluster yourClusterName --region yourRegionName CLUSTER NODEGROUP STATUS CREATED MIN SIZE MAX SIZE DESIRED CAPACITY INSTANCE TYPE IMAGE ID ASG NAME TYPE clusterName ngWorkers ACTIVE Date&Time * * * m5.large AL2_x86_64 ASGNAME managed
****节点状态
$ kubectl get nodes NAME STATUS ROLES AGE VERSION ip-***-**-**-***.region.compute.internal Ready <none> 4h v1.2x.x-eks-xx ip-***-**-***-**.region.compute.internal Ready <none> 4h v1.2x.x-eks-xx Create a node group with custom parameters
使用自定义参数创建节点组
-
在配置文件中定义新节点组的参数。例如:
kind: ClusterConfig apiVersion: eksctl.io/v1alpha5 metadata: name: clusterName region: region nodeGroups: - name: ngWorkers availabilityZones: ["az-name"] desiredCapacity: 3 instanceType: m5.large iam: instanceProfileARN: "arn:aws:iam::11111:instance-profile/eks-nodes-base-role" #Attaching IAM role instanceRoleARN: "arn:aws:iam::1111:role/eks-nodes-base-role" privateNetworking: true securityGroups: withShared: true withLocal: true attachIDs: ['sg-11111', 'sg-11112'] ssh: publicKeyName: 'my-instance-key' kubeletExtraConfig: kubeReserved: cpu: "300m" memory: "300Mi" ephemeral-storage: "1Gi" kubeReservedCgroup: "/kube-reserved" systemReserved: cpu: "300m" memory: "300Mi" ephemeral-storage: "1Gi" tags: 'environment': 'development' - name: ng-2-builders #example of a nodegroup that uses 50% spot instances and 50% on demand instances: minSize: 2 maxSize: 5 instancesDistribution: maxPrice: 0.017 instanceTypes: ["t3.small", "t3.medium"] # At least two instance types should be specified onDemandBaseCapacity: 0 onDemandPercentageAboveBaseCapacity: 50 spotInstancePools: 2 tags: 'environment': 'production'
有关支持的参数和 nodegroup 类型的更多信息,请参阅 eksctl 网站上的 Nodegroups。
-
要使用配置文件再创建一个节点组,请运行以下命令:
$ eksctl create nodegroup --config-file=yourConfigFileName
-
(可选)步骤 2 中的命令部署 AWS CloudFormation 堆栈以为 EKS 节点组创建资源。要检查堆栈状态,请访问 CloudFormation 控制台并确认 AWS 区域与集群的区域相同。
堆栈处于 CREATE\ _COMPLETE 状态后,eksctl 命令成功退出。 -
要确认新节点组已附加到集群并验证节点是否已加入集群,请运行以下命令:
$ kubectl get nodes $ eksctl get nodegroups --cluster yourClusterName --region yourRegionName
在输出中,确认节点的状态为 READY 且节点组状态为 ACTIVE。例如:
节点组状态$ eksctl get nodegroups --cluster yourClusterName --region yourRegionName CLUSTER NODEGROUP STATUS CREATED MIN SIZE MAX SIZE DESIRED CAPACITY INSTANCE TYPE IMAGE ID ASG NAME TYPE clusterName ngWorkers ACTIVE Date&Time * * * m5.large AL2_x86_64 ASGNAME managed
Node status
$ kubectl get nodes NAME STATUS ROLES AGE VERSION ip-***-**-**-***.region.compute.internal Ready <none> 4h v1.2x.x-eks-xx ip-***-**-***-**.region.compute.internal Ready <none> 4h v1.2x.x-eks-xx
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 9 个月前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前