第 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_selectorpostgres_selector 将自动化控制器 pod 限制为仅在匹配所有指定键或值对的节点上运行。
  • tolerationspostgres_tolerations 允许将自动化控制器 pod 调度到具有匹配污点的节点。如需了解更多详细信息,请参阅 Kubernetes 文档中的 污点和容限

下表显示了可以在 YAML 的自动化控制器规格部分(或使用 OpenShift UI 表单)上设置的设置和字段。

Name描述default

postgres_image

要拉取镜像的路径

postgres

postgres_image_version

要拉取的镜像版本

13

node_selector

Automationcontroller pod 的 nodeSelector

“”’’

topology_spread_constraints

Automationcontroller pod 的 topologySpreadConstraints

“”’’

容限(tolerations)

Automationcontroller pod 的容限

“”’’

annotations

Automationcontroller pod 的注解

“”’’

postgres_selector

Postgres pod 的 nodeSelector

“”’’

postgres_tolerations

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"
Copy to Clipboard

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat