使用污点和容忍度

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

在基础设施节点上调度 Collector

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

前提条件

  • 必须安装 Alauda Container Platform 原生应用可观测性(之前称为 Alauda Build of OpenTelemetry v2)Operator。
  • 必须使用适当的标签和污点配置 基础设施节点。

操作步骤

  1. 验证基础设施节点是否已正确添加标签和污点:

    kubectl get nodes -l node-role.kubernetes.io/infra= -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
  2. 使用 nodeSelector 和 tolerations 创建或更新 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 pod 限制为仅在与指定标签匹配的节点上运行。在此示例中,节点具有 node-role.kubernetes.io/infra: "" 标签。
    2. spec.tolerations:允许 Collector pod 调度到具有匹配污点的节点上。NoSchedule 效果会阻止没有此容忍度的其他 pod 调度到这些节点上。
    3. spec.tolerations[].operator:设置为 Equal,要求污点键和值完全匹配。

验证

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

kubectl get pods -n opentelemetry-collector -o wide

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