Kubernetes v1.36 [alpha](默认禁用)拓扑感知调度 (Topology-Aware Scheduling, TAS) 是一种放置调度算法,旨在为给定的 PodGroup 找到最佳放置位置,并确保所有 Pod 都并置在同一个拓扑域内。用户可以通过修改 TAS 插件配置来根据特定需求调整 TAS。
调度器包含新的和扩展的内置插件,这些插件实现了 TAS 扩展点
TopologyPlacement:实现 PlacementGeneratePlugin 接口。它通过根据请求的拓扑 key(在 PodGroup 中定义)的不同值对节点进行分组,从而生成候选放置位置。
NodeResourcesFit:扩展以实现 PlacementScorePlugin 接口。它遵循与标准 Pod 装箱类似的逻辑,根据放置位置内所有节点的分配比率对放置位置进行评分。它使用 MostAllocated 策略来最大化放置位置内的资源利用率,并继承标准 Pod 逐个插件设置中的资源权重。
PodGroupPodsCount:实现 PlacementScorePlugin 接口。它根据 PodGroup 中可以成功调度的 Pod 总数对候选放置位置进行评分。
默认情况下,NodeResourcesFit 和 PodGroupPodsCount 插件配置为相等的权重(默认均为 1),以保持装箱逻辑与尽可能多地调度 Pod 之间的良好平衡。
您可以在 KubeSchedulerConfiguration 中调整这些权重,或调整装箱策略中的资源权重。以下是一个示例片段,展示了如何更改两个插件的权重,以及如何覆盖 NodeResourcesFit 的资源权重。后者的更改将同时应用于逐个 Pod 和放置评分算法
apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
profiles:
- schedulerName: default-scheduler
plugins:
placementScore:
enabled:
# 1) Change the default weights of the placement score plugins
- name: NodeResourcesFit
weight: 2
- name: PodGroupPodsCount
weight: 5
pluginConfig:
- name: NodeResourcesFit
args:
# 2) Changing the scoring resource weights for both pod-by-pod and placement scoring
# algorithms
scoringStrategy:
# The type will only be considered in pod-by-pod scheduling. Placement scoring always
# uses MostAllocated strategy
type: LeastAllocated
# Resource weights will be used in both pod-by-pod and placement scoring algorithms
resources:
- name: cpu
weight: 2
- name: memory
weight: 3