使用 Taints 和 Tolerations

您可以使用 taints 和 tolerations 来控制 OpenTelemetry Collector pods 调度到哪些节点上。当您希望为可观测性工作负载专门使用特定的 基础设施节点 时,这非常有用。

将 Collector 调度到基础设施节点上

要将 OpenTelemetry Collector 调度到基础设施节点上,请在 OpenTelemetryCollector 自定义资源中配置 nodeSelectortolerations 字段。

前提条件

  • 必须安装 Alauda Build of OpenTelemetry v2 Operator。
  • 必须为 基础设施节点 配置适当的标签和 taints。

操作步骤

  1. 验证您的基础设施节点是否已正确添加标签并设置 taints:

    kubectl get nodes -l node-role.kubernetes.io/infra= -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
  2. 使用 nodeSelectortolerations 创建或更新 OpenTelemetryCollector 资源:

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: opentelemetry-collector
    spec:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
      tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/infra
          value: reserved
          operator: Equal
      config:
        # ... collector config
    1. spec.nodeSelector:将 Collector pods 限制为仅在匹配指定标签的节点上运行。在本示例中,节点带有 node-role.kubernetes.io/infra: "" 标签。
    2. spec.tolerations:允许将 Collector pods 调度到带有匹配 taints 的节点上。NoSchedule 效果会阻止没有此 toleration 的其他 pods 调度到这些节点上。
    3. spec.tolerations[].operator:设置为 Equal,以要求 taint 的 key 和 value 完全匹配。

验证

验证 Collector pods 是否已调度到基础设施节点上:

kubectl get pods -n opentelemetry-collector -o wide

确认 NODE 列显示的是基础设施节点名称。