第 1 章 调度日志记录资源


您可以通过定义节点选择器、污点和容限以及关联性和反关联性配置来调度日志记录资源。

节点选择器
节点选择器指定一个键值对映射,该映射使用 pod 中指定的自定义标签和选择器来定义。要使 pod 有资格在节点上运行,pod 必须具有与节点上标签相同的键值对。
污点和容限
污点和容限控制哪些 pod 应该或不应该调度到节点上。
关联性和反关联性
通过 pod 关联性和 pod 反关联性,您可以根据其他 pod 上的键值标签限制 pod 有资格调度到哪些节点。
重要

如果同时配置 nodeSelector 和 'nodeAffinity'fields,则必须满足这两个字段的条件才能将 pod 调度到候选节点。

1.1. 使用容忍度来控制日志收集器 pod 放置

默认情况下,日志收集器 pod 具有以下 tolerations 配置:

apiVersion: v1
kind: Pod
metadata:
  name: collector-example
  namespace: openshift-logging
spec:
# ...
  collection:
    type: vector
    tolerations:
    - effect: NoSchedule
      key: node-role.kubernetes.io/master
      operator: Exists
    - effect: NoSchedule
      key: node.kubernetes.io/disk-pressure
      operator: Exists
    - effect: NoExecute
      key: node.kubernetes.io/not-ready
      operator: Exists
    - effect: NoExecute
      key: node.kubernetes.io/unreachable
      operator: Exists
    - effect: NoSchedule
      key: node.kubernetes.io/memory-pressure
      operator: Exists
    - effect: NoSchedule
      key: node.kubernetes.io/pid-pressure
      operator: Exists
    - effect: NoSchedule
      key: node.kubernetes.io/unschedulable
      operator: Exists
# ...
Copy to Clipboard Toggle word wrap

先决条件

  • 已安装 Red Hat OpenShift Logging Operator 和 OpenShift CLI (oc)。

流程

  1. 运行以下命令,将污点添加到要在其上调度日志记录收集器 pod 的节点:

    $ oc adm taint nodes <node_name> <key>=<value>:<effect>
    Copy to Clipboard Toggle word wrap

    示例命令

    $ oc adm taint nodes node1 collector=node:NoExecute
    Copy to Clipboard Toggle word wrap

    本例在 node1 上放置一个键为 collector 且值为 node 的污点,污点效果是 NoExecute。您必须使用 NoExecute 污点设置。NoExecute 仅调度与污点匹配的 pod,并删除不匹配的现有 pod。

  2. 编辑 ClusterLogging 自定义资源(CR)的 collection 小节,以配置日志记录收集器 Pod 的容忍度:

    apiVersion: logging.openshift.io/v1
    kind: ClusterLogging
    metadata:
    # ...
    spec:
    # ...
      collection:
        type: vector
        tolerations:
        - key: collector 
    1
    
          operator: Exists 
    2
    
          effect: NoExecute 
    3
    
          tolerationSeconds: 6000 
    4
    
        resources:
          limits:
            memory: 2Gi
          requests:
            cpu: 100m
            memory: 1Gi
    # ...
    Copy to Clipboard Toggle word wrap
    1
    指定添加到节点的键。
    2
    指定 Exists 运算符,以要求匹配 key/value/effect 参数。
    3
    指定 NoExecute 效果。
    4
    (可选)指定 tolerationSeconds 参数,以设置 pod 在被逐出前可以保持绑定到节点的时长。

此容忍度与 oc adm taint 命令创建的污点匹配。具有此容忍度的 pod 可以调度到 node1 上。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat