为 Logging 存储规划 Infra 节点

本指南说明了在专用 Kubernetes infra 节点上运行 Logging 存储插件时需要考虑的规划事项。

目标

  • 隔离资源:防止与业务工作负载发生资源竞争。
  • 确保稳定性:减少驱逐和调度冲突。
  • 简化管理:通过一致的调度规则集中管理 infra 组件。

何处配置放置策略

  • 对于 Alauda Container Platform Log Storage for Elasticsearch,请在 Installation 中通过 spec.valuesOverride.ait/chart-alauda-log-center.global.nodeSelectorspec.valuesOverride.ait/chart-alauda-log-center.global.tolerations 配置放置策略。
  • 对于 Alauda Container Platform Log Storage for ClickHouse,请在控制台的 Advanced Configuration 中配置放置策略,或在 Installation 中通过 spec.config.components.nodeSelectorspec.config.components.tolerations 配置。

不要通过 patch 生成的 StatefulSets、Deployments 或 ClickHouseInstallation resources 来作为将 Logging 存储工作负载放置到 infra 节点上的标准方式。

配置放置策略前

  1. 按照 集群节点规划 规划 infra 节点。
  2. 确认你的存储是否使用 LocalVolume 或其他带有 spec.nodeAffinity 的 PV。
  3. 确保所选的 infra 节点能够同时满足调度规则和存储放置约束。

检查 Local PV 和 nodeAffinity

如果你的组件使用本地存储(例如 TopoLVM、本地 PV),请确认 PV 是否具有 spec.nodeAffinity。如果有,请执行以下任一操作:

  1. pv.spec.nodeAffinity 引用的所有节点添加到 infra node group,或者
  2. 使用不带 node affinity 的 storage class 重新部署组件(例如 Ceph/RBD)。

示例(Elasticsearch):

# 1) Get ES PVCs
kubectl get pvc -n cpaas-system | grep elastic

# 2) Inspect one PV
kubectl get pv elasticsearch-log-node-pv-192.168.135.243 -o yaml

如果 PV 显示:

spec:
  local:
    path: /cpaas/data/elasticsearch/data
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - 192.168.135.243

那么 Elasticsearch 数据会固定到节点 192.168.135.243。请确保该节点属于 infra node group,或者迁移存储。

同样的原则也适用于任何使用绑定节点本地存储的 Logging 存储组件。

历史 Kafka 和 ZooKeeper 节点

由于历史原因,请确保 Kafka 和 ZooKeeper 节点也被标记/加上污点为 infra:

kubectl get nodes -l kafka=true
kubectl get nodes -l zk=true
# Add the listed nodes into infra nodes as above

故障排查

常见问题及修复方法:

问题诊断解决方案
Pod 卡在 Pending 状态kubectl describe pod <pod> | grep Events添加 tolerations 或调整 selectors
taint/toleration 不匹配kubectl describe node <node> | grep Taints为工作负载添加匹配的 tolerations
资源饥饿kubectl top nodes -l node-role.kubernetes.io/infra扩容 infra 节点或调整资源请求

示例错误:

Events:
  Warning  FailedScheduling  2m  default-scheduler  0/3 nodes are available:
  3 node(s) had untolerated taint {node-role.kubernetes.io/infra: true}

修复方法:为插件配置添加匹配的 tolerations,并确保所选的 infra 节点也满足所需的存储放置约束。