第 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 表单)上设置的设置和字段。
Name | 描述 | 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
,这意味着最大地分散到可用节点上。因此,如果有三个匹配的计算节点和三个 pod,则会为每个计算节点分配一个 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"
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"