1.2. 自定义 Service Operator 容限


容限根据匹配的污点控制调度程序用于 pod 放置的节点或节点组。您可以覆盖默认容限,并为每个服务添加额外的容限,以控制调度程序放置服务 pod 的位置。

先决条件

  • 已使用污点配置了 Node 自定义资源(CR)。

流程

  1. 查看默认服务 Operator 容限:

    $ oc get deployment <service>-operator-controller-manager -o yaml | yq .spec.template.spec.tolerations
    - effect: NoExecute
      key: node.kubernetes.io/not-ready
      operator: Exists
      tolerationSeconds: 120
    - effect: NoExecute
      key: node.kubernetes.io/unreachable
      operator: Exists
      tolerationSeconds: 120
    - effect: NoSchedule
      key: node.example.com/infra
      operator: Equal
      value: infra
    • &lt;service> 替换为您要查看容限的服务的名称,如 infrakeystone

    如需有关容限字段的信息,请参阅了解污点和容限

  2. 在工作站上创建名为 openstack_operator_overrides.yaml 的文件,或者打开该文件(如果已存在):

    apiVersion: operator.openstack.org/v1beta1
    kind: OpenStack
    metadata:
      name: openstack
      namespace: openstack-operators
  3. 根据您的环境需要覆盖容限配置或添加新容限:

    spec:
      operatorOverrides:
      - name: <service>
        tolerations:
        - effect: NoSchedule
          key: node.example.com/infra
          operator: Equal
          value: infra
          tolerationSeconds: 600
      - name: <service>
        tolerations:
        ...
    • tolerations.effect: 指定在容限字符串与污点字符串不匹配时要与 pod 执行的操作。设置为以下有效值之一:

      • NoSchedule :与污点不匹配的新 pod 不会调度到该节点上。
      • PreferNoSchedule: 与污点不匹配的新 pod 可能会调度到该节点上,但调度程序不会将这些 pod 调度到该节点上。
      • NoExecute: 与污点不匹配的新 pod 无法调度到该节点上。
    • tolerations.key :代表污点的任何字符串,最多 253 个字符。有关任何 RHOCP 集群中可用的默认污点列表,请参阅了解污点和容限
    • tolerations.operator: 指定在将 pod 调度到节点时是否 使用值 字符串。设置为以下有效值之一:

      • 等于 :键/值/effect 参数必须匹配。这是默认值。
      • 存在 : key/effect 参数必须匹配。您必须保留一个空 value 参数,该参数与任何参数匹配。
    • tolerations.value: 任何字符串,最多 63 个字符,必须与为污点设置的值匹配。当 Operator 被设置为 Exists 时,不要设置。
    • tolerations.tolerationSeconds :一个可选字段,指定 pod 在被驱除前可以保持与节点绑定的时长,以秒为单位。
  4. 更新 OpenStack Operator:

    $ oc apply -f openstack_operator_overrides.yaml -n openstack-operators
  5. 确认应用了更新的容限:

    $ oc get deployment <service>-operator-controller-manager -o yaml | yq .spec.template.spec.tolerations
    - effect: NoExecute
      key: node.kubernetes.io/not-ready
      operator: Exists
      tolerationSeconds: 120
    - effect: NoExecute
      key: node.kubernetes.io/unreachable
      operator: Exists
      tolerationSeconds: 120
    - effect: NoSchedule
      key: node.example.com/infra
      operator: Equal
      value: infra
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部