第 3 章 指定专用节点
kubernetes 集群在多个虚拟机或节点之上运行(通常位于 2 到 20 个节点之间的任何位置)。pod 可以调度到其中任何节点上。当您创建或调度新 pod 时,请使用 topology_spread_constraints 设置来配置在调度或创建时如何在底层节点上分布新 pod。
不要将 pod 调度到单个节点上,因为如果该节点失败,则这些 pod 提供的服务也会失败。
将 control plane 节点调度到不同节点上运行到自动化作业 pod。如果 control plane pod 与作业 pod 共享节点,control plane 可能会成为资源不足并降低整个应用程序的性能。
3.1. 将 Pod 分配给特定的节点
您可以将 operator 创建的控制器 pod 限制为在特定的节点子集中运行。
-
node_selector和postgres_selector将自动化控制器 pod 限制为仅在匹配所有指定键或值对的节点上运行。 -
tolerations和postgres_tolerations允许将自动化控制器 pod 调度到具有匹配污点的节点。如需了解更多详细信息,请参阅 Kubernetes 文档中的 污点和容限。
下表显示了可以在 YAML 的自动化控制器规格部分(或使用 Openshift UI 表单)上设置的设置和字段。
| 名称 | 描述 | default |
|---|---|---|
|
| 要拉取镜像的路径 | postgres |
|
| 要拉取的镜像版本 | 13 |
|
| Automationcontroller pod 的 nodeSelector | “”’’ |
|
| Automationcontroller pod 的 topologySpreadConstraints | “”’’ |
|
| Automationcontroller pod 的容限 | “”’’ |
|
| Automationcontroller pod 的注解 | “”’’ |
|
| Postgres pod 的 nodeSelector | “”’’ |
|
| Postgres pod 的容限 | “”’’ |
topology_spread_constraints 有助于优化在与节点选择器匹配的计算节点上分散 control plane pod。例如,如果此选项的 maxSkew 参数设置为 100,这意味着最大地分散到可用节点上。因此,如果存在与计算节点和 3 个 pod 匹配的 3 个 pod,则会为每个计算节点分配 1 个 pod。此参数有助于防止 control plane pod 相互竞争资源。
将控制器 pod 限制到特定节点的自定义配置示例
spec:
...
node_selector: |
disktype: ssd
kubernetes.io/arch: amd64
kubernetes.io/os: linux
topology_spread_constraints: |
- maxSkew: 100
topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/name: "<resourcename>"
tolerations: |
- key: "dedicated"
operator: "Equal"
value: "AutomationController"
effect: "NoSchedule"
postgres_selector: |
disktype: ssd
kubernetes.io/arch: amd64
kubernetes.io/os: linux
postgres_tolerations: |
- key: "dedicated"
operator: "Equal"
value: "AutomationController"
effect: "NoSchedule"