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

您可以通过在 pod 上使用容忍度来确保日志记录收集器 pod 在哪些节点上运行,并防止其他工作负载使用这些节点。

您可以通过 ClusterLogging 自定义资源(CR)将容忍度应用到日志记录收集器 pod,并通过节点规格将污点应用到节点。您可以使用污点和容限来确保 pod 不会因为内存和 CPU 问题而被驱除。

默认情况下,日志记录收集器 pod 具有以下容忍度:

tolerations:
- key: "node-role.kubernetes.io/master"
  operator: "Exists"
  effect: "NoExecute"

先决条件

  • 必须安装 Cluster Logging 和 Elasticsearch。

流程

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

    $ oc adm taint nodes <node-name> <key>=<value>:<effect>

    例如:

    $ oc adm taint nodes node1 collector=node:NoExecute

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

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

      collection:
        logs:
          type: "fluentd"
          fluentd:
            tolerations:
            - key: "collector"  1
              operator: "Exists"  2
              effect: "NoExecute"  3
              tolerationSeconds: 6000  4
    1
    指定添加到节点的键。
    2
    指定 Exists 运算符,以要求匹配 key/value/effect 参数。
    3
    指定 NoExecute 效果。
    4
    (可选)指定 tolerationSeconds 参数,以设置 pod 在被逐出前可以保持绑定到节点的时长。

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