在 Azure Stack HCI 23H2) (AKS 管理群集的节点池
适用于:Azure Stack HCI 版本 23H2
注意
有关在 Azure Stack HCI 22H2 上的 AKS 中管理节点池的信息,请参阅 管理节点池。
在 Azure Arc 启用的 AKS 中,相同配置的节点将分组到 节点池中。 这些节点池包含运行应用程序的底层 VM。 本文介绍如何在 AKS Arc 中创建和管理群集的节点池。
创建 Kubernetes 群集
若要开始,请创建包含单节点池的 Kubernetes 群集:
az aksarc create -n <cluster name> -g <resource group> --custom-location <custom location Id> --vnet-ids <vnet id> --generate-ssh-keys --load-balancer-count <load balancer count>
添加节点池
可以使用 命令将节点池添加到现有群集 az aksarc nodepool add
。 确保节点池的名称与现有节点池的名称不同:
az aksarc nodepool add --name <node pool name> -g <resource group> --cluster-name <cluster name> --os-sku <Linux or Windows> --node-count <count> --node-vm-size <vm size>
获取节点池的配置信息
若要查看节点池的配置,请使用 az aksarc nodepool show
命令:
az aksarc nodepool show --cluster-name <cluster name> -n <node pool name> -g <resource group>
示例输出:
{
"availabilityZones": null,
"count": 1,
"extendedLocation": null,
"id":
"/subscriptions/<subscription>/resourceGroups/edgeci-registration-rr1s46r1710<resource
group>/providers/Microsoft.Kubernetes/connectedClusters/<cluster
name>/providers/Microsoft.HybridContainerService/provisionedClusterInstances/default/agentPools/<nodepoolname>",
"location": "westeurope",
"name": "nodepoolname",
"nodeImageVersion": null,
"osSku": "CBLMariner",
"osType": "Linux",
"provisioningState": "Succeeded",
"resourceGroup": "resourcegroup",
"status": {
"errorMessage": null,
"operationStatus": null,
"readyReplicas": [
{
"count": 1,
"vmSize": "Standard\_A4\_v2"
}
]
},
"systemData": {
…
},
"tags": null,
"type":
"microsoft.hybridcontainerservice/provisionedclusterinstances/agentpools",
"vmSize": "Standard\_A4\_v2"
}
指定部署到节点池的最大 Pod 数
可以在群集创建时或在创建新节点池时配置可部署到节点的最大 Pod 数。 如果未在创建节点池时指定 maxPods
,则节点池部署的默认值为最多 110 个 Pod:
az aksarc nodepool add --cluster-name <cluster name> -n <node pool name> -g <resource group> --max-pods 50 --yes
缩放节点池
可以纵向扩展或缩减节点池中的节点数。
若要缩放节点池中的节点数,请使用 az aksarc nodepool scale
命令。 以下示例将名为 的节点池 nodepool1
中的节点数缩放为 2 个:
az aksarc nodepool scale --cluster-name <cluster name> -n nodepool1 -g <resource group> --node-count 2 --yes
删除节点池
如果需要删除节点池,请使用 az aksarc nodepool delete
命令:
az aksarc nodepool delete --cluster-name <cluster name> -n <node pool name> -g <resource group> --yes
指定节点池的污点或标签
创建节点池时,可以向其添加污点或标签。 添加污点或标签时,该节点池中的所有节点也会获得该污点或标签。
重要
应使用 az aksarc nodepool
向整个节点池的节点添加污点或标签。 不建议使用 kubectl
将污点或标签应用于节点池中的单个节点。
设置节点池排斥
使用
az aksarc nodepool add
命令创建具有排斥的节点池。 指定名称taintnp
并使用--node-taints
参数为污点指定sku=gpu:NoSchedule
:az aksarc nodepool add \ --resource-group myResourceGroup \ --cluster-name myAKSCluster \ --name taintnp \ --node-count 1 \ --node-taints sku=gpu:NoSchedule \ --no-wait
使用
az aksarc nodepool list
命令检查节点池的状态:az aksarc nodepool list -g myResourceGroup --cluster-name myAKSCluster
以下示例输出显示
taintnp
节点池使用指定的nodeTaints
创建节点:[ { ... "count": 1, ... "name": "taintnp", ... "provisioningState": "Succeeded", ... "nodeTaints": [ "sku=gpu:NoSchedule" ], ... }, ... ]
排斥信息将显示在 Kubernetes 中,以便于处理节点的计划规则。 Kubernetes 计划程序可以使用污点和容许来限制哪些工作负载可以在节点上运行。
- 将排斥应用到指明了只能计划特定 pod 的节点。
- 然后 ,将容忍 应用于允许它们“容忍”节点的污点的 Pod。
设置节点池容许
在上一步中,在创建节点池时应用 sku=gpu:NoSchedule
了污点。 以下示例 YAML 清单使用容许允许 Kubernetes 计划程序在该节点池中的节点上运行 NGINX Pod:
创建名为 nginx-toleration.yaml 的文件,并复制/粘贴以下示例 YAML:
apiVersion: v1 kind: Pod metadata: name: mypod spec: containers: - image: mcr.microsoft.com/oss/nginx/nginx:1.15.9-alpine name: mypod resources: requests: cpu: 100m memory: 128Mi limits: cpu: 1 memory: 2G tolerations: - key: "sku" operator: "Equal" value: "gpu" effect: "NoSchedule"
使用
kubectl apply
命令计划 pod:kubectl apply -f nginx-toleration.yaml
只需花费几秒钟时间即可计划 pod 并提取 NGINX 映像。
使用
kubectl describe pod
命令检查状态:kubectl describe pod mypod
以下压缩的示例输出显示
sku=gpu:NoSchedule
应用了容忍。 在 “事件 ”部分中,计划程序将 Pod 分配给节点moc-lbeof1gn6x3
:[...] Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s sku=gpu:NoSchedule Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 54s default-scheduler Successfully assigned default/mypod to moc-lbeof1gn6x3 Normal Pulling 53s kubelet Pulling image "mcr.microsoft.com/oss/nginx/nginx:1.15.9-alpine" Normal Pulled 48s kubelet Successfully pulled image "mcr.microsoft.com/oss/nginx/nginx:1.15.9-alpine" in 3.025148695s (3.025157609s including waiting) Normal Created 48s kubelet Created container Normal Started 48s kubelet Started container
只有应用了此容忍的 Pod 才能在 中的
taintnp
节点上计划。 任何其他 Pod 将在 nodepool1 节点池中计划。 如果创建更多节点池,可以使用污点和容忍来限制可在这些节点资源上计划的 pod。
设置节点池标签
有关详细信息,请参阅 在已启用 Azure Arc 的 AKS 群集中使用标签。 ::: zone-end
后续步骤
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈