Skip to content

Commit 9cc579c

Browse files
44past4ania-borowiec
authored andcommitted
Apply review comments
1 parent f08db04 commit 9cc579c

7 files changed

Lines changed: 144 additions & 97 deletions

File tree

content/en/docs/concepts/scheduling-eviction/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ of terminating one or more Pods on Nodes.
2626
* [Pod Scheduling Readiness](/docs/concepts/scheduling-eviction/pod-scheduling-readiness/)
2727
* [PodGroup Scheduling](/docs/concepts/scheduling-eviction/podgroup-scheduling/)
2828
* [Gang Scheduling](/docs/concepts/scheduling-eviction/gang-scheduling/)
29+
* [Topology-aware Scheduling](/docs/concepts/scheduling-eviction/topology-aware-scheduling/)
2930
* [Descheduler](https://github.com/kubernetes-sigs/descheduler#descheduler-for-kubernetes)
3031
* [Node Declared Features](/docs/concepts/scheduling-eviction/node-declared-features/)
3132

content/en/docs/concepts/scheduling-eviction/podgroup-scheduling.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,35 @@ It iterates over the Pods and performs the following for each:
7979
If it returns a `Success` status for any Pod, the PodGroup is deemed feasible.
8080
If the algorithm processes all Pods without achieving a `Success` status, the PodGroup is considered unschedulable.
8181

82+
## Placement scheduling algorithm
83+
{{< feature-state feature_gate_name="TopologyAwareWorkloadScheduling" >}}
84+
85+
Placement scheduling algorithm is an alternative PodGroup scheduling algorithm, which uses
86+
[scheduling plugins](/docs/reference/scheduling/config/#scheduling-plugins) to find the optimal
87+
placement for the considered PodGroup. Users can accomodate the algorithm to their specific needs
88+
by using and configuring plugins.
89+
90+
The algorithm proceeds in three main phases for a given PodGroup:
91+
92+
### Phase 1: Candidate placement generation
93+
94+
Generates candidate *placements* (subsets of nodes, that are theoretically feasible for PodGroup
95+
assignment), for example based on the PodGroup's scheduling constraints (which can be defined
96+
in the PodGroup object).
97+
98+
This phase executes as extension point: `PlacementGeneratePlugin`.
99+
100+
### Phase 2: Pod-level filtering and feasibility check
101+
102+
Validates each proposed placement, by running a default PodGroup scheduling algorithm, to see if
103+
the required number of Pods from the PodGroup can fit. If they can, the placement is marked as feasible.
104+
105+
### Phase 3: Placement scoring and selection
106+
107+
Scores all feasible placements to select the optimal domain for the PodGroup.
108+
109+
This phase executes as extension point: `PlacementScorePlugin`.
110+
82111
### Limitations
83112

84113
The PodGroup scheduling algorithm relies on specific Pod sorting and may fail to find a valid placement

content/en/docs/concepts/scheduling-eviction/resource-bin-packing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ weight: 80
1010

1111
<!-- overview -->
1212

13+
{{< note >}}
14+
This article applies to resource bin packing in context of scheduling of a single pod. For bin packing when scheduling pod groups, please read the [article about Topology-aware Scheduling](/docs/concepts/scheduling-eviction/topology-aware-scheduling/).
15+
{{< /note >}}
16+
1317
In the [scheduling-plugin](/docs/reference/scheduling/config/#scheduling-plugins) `NodeResourcesFit` of kube-scheduler, there are two
1418
scoring strategies that support the bin packing of resources: `MostAllocated` and `RequestedToCapacityRatio`.
1519

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Topology-Aware Workload Scheduling
3+
content_type: concept
4+
weight: 10
5+
---
6+
7+
<!-- overview -->
8+
{{< feature-state feature_gate_name="TopologyAwareWorkloadScheduling" >}}
9+
10+
*Topology-Aware Scheduling* (TAS) is a [placement scheduling algorithm](/docs/concepts/scheduling-eviction/podgroup-scheduling/#placement-scheduling-algorithm)
11+
that allows to find the optimal placement for the considered PodGroup, guaranteeing that all pods
12+
will be collocated within the same topology domain. Users can accomodate TAS to their specific
13+
needs by changing TAS plugins configuration.
14+
15+
## Scheduling framework: TAS plugins configuration
16+
17+
The scheduler includes new and extended in-tree plugins that implement the TAS extension points:
18+
19+
* `TopologyPlacement`: Implements the `PlacementGeneratePlugin` interface. It generates candidate
20+
placements by grouping nodes based on the distinct values of the requested topology `key` (defined
21+
in the PodGroup).
22+
23+
* `NodeResourcesFit`: Extended to implement the `PlacementScorePlugin` interface. Following
24+
similar logic to standard pod bin-packing, it scores placements based on the allocation ratio
25+
across all nodes within the placement. It uses the `MostAllocated` strategy to maximize resource
26+
utilization within a placement, and it inherits resource weights from the standard pod-by-pod
27+
plugin settings.
28+
29+
* `PodGroupPodsCount`: Implements the `PlacementScorePlugin` interface. It scores candidate
30+
placements based on the total number of pods in the PodGroup that you can successfully schedule.
31+
32+
### Customizing plugin weights and bin-packing resource weights
33+
34+
By default, the `NodeResourcesFit` and `PodGroupPodsCount` plugins are configured with equal
35+
weights (both default to 1) to maintain a good balance between bin-packing logic and scheduling as
36+
many pods as possible.
37+
38+
You can adjust these weights, or the resource weights in the bin-packing strategy in your
39+
KubeSchedulerConfiguration. Here is an example snippet showing how to change the weights for both
40+
plugins, and how to override the `NodeResourcesFit` resource weights. The latter change will apply
41+
both to pod-by-pod and placement scoring algorithms:
42+
43+
```yaml
44+
apiVersion: kubescheduler.config.k8s.io/v1
45+
kind: KubeSchedulerConfiguration
46+
profiles:
47+
- schedulerName: default-scheduler
48+
plugins:
49+
placementScore:
50+
enabled:
51+
# 1) Change the default weights of the placement score plugins
52+
- name: NodeResourcesFit
53+
weight: 2
54+
- name: PodGroupPodsCount
55+
weight: 5
56+
pluginConfig:
57+
- name: NodeResourcesFit
58+
args:
59+
# 2) Changing the scoring resource weights for both pod-by-pod and placement scoring
60+
# algorithms
61+
scoringStrategy:
62+
# The type will only be considered in pod-by-pod scheduling. Placement scoring always
63+
# uses MostAllocated strategy
64+
type: LeastAllocated
65+
# Resource weights will be used in both pod-by-pod and placement scoring algorithms
66+
resources:
67+
- name: cpu
68+
weight: 2
69+
- name: memory
70+
weight: 3
71+
```
72+
73+
## {{% heading "whatsnext" %}}
74+
75+
* Learn more about [Topology-aware scheduling API](/docs/concepts/workloads/workload-api/topology-aware-scheduling/).
76+
* Read about [pod group scheduling](/docs/concepts/scheduling-eviction/podgroup-scheduling/).
77+
* Read about [pod group policies](/docs/concepts/workloads/workload-api/policies/).

content/en/docs/concepts/workloads/workload-api/_index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ The `controllerRef` field links the Workload back to the specific high-level obj
6464
such as a [Job](/docs/concepts/workloads/controllers/job/) or a custom CRD. This is useful for observability and tooling.
6565
This data is not used to schedule or manage the Workload.
6666

67-
TBD: Add section on desired count and topology aware scheduling
68-
6967
## {{% heading "whatsnext" %}}
7068

7169
* See how to [reference a Workload](/docs/concepts/workloads/pods/workload-reference/) in a Pod.

content/en/docs/concepts/workloads/workload-api/topology-aware-scheduling.md

Lines changed: 13 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ weight: 10
1010
*Topology-Aware Scheduling* (TAS) is a feature of the Workload API that optimizes the placement of
1111
pods within the cluster.
1212

13-
TAS ensures that all pods within a PodGroup are co-located into a specific physical network domain,
13+
TAS ensures that all pods within a PodGroup are co-located into a specific topology domain,
1414
such as a single server rack or zone. This minimizes inter-pod communication latency and prevents
1515
workload fragmentation across the cluster infrastructure.
1616

1717
## Topology-aware scheduling with gang scheduling policy
1818

1919
When applied to PodGroups with `gang` scheduling policy, TAS simulates the potential assignment
2020
(*placement*) of the full group of pods at once. It guarantees that at least the specified
21-
`minCount` pods can fit together into the same physical network domain before committing resources.
21+
`minCount` pods can fit together into the same topology domain before committing resources.
2222
If no feasible placement is found, the entire PodGroup becomes unschedulable.
2323

2424
This is the recommended approach for workloads like distributed AI and ML training that strictly
2525
require proximity to minimize inter-pod communication latency.
2626

2727
If new pods are added to the PodGroup where some pods are already scheduled (for example, if pods
28-
are restarted), the scheduler will force all new incoming pods to land on the exact same topology
28+
are recreated), the scheduler will force all new incoming pods to land on the exact same topology
2929
domain where the existing pods currently reside. If that specific domain lacks sufficient capacity
3030
for the new pods, the pods will remain pending - even if it means that less than `minCount` pods
3131
are scheduled at this point.
@@ -52,25 +52,22 @@ insufficient capacity (in which case the new pods will remain pending).
5252

5353
## API configuration: scheduling constraints
5454

55-
TAS constraints are defined on PodGroup or PodGroupTemplate level.
55+
Every PodGroup (or PodGroupTemplate) may optionally declare the `schedulingConstraints` field,
56+
which is interpreted by the [placement-based PodGroup scheduling algorithm](/docs/concepts/scheduling-eviction/podgroup-scheduling/#placement-scheduling-algorithm).
57+
If constraints are defined in PodGroupTemplate, they will be copied to referencing PodGroups.
5658

57-
Every PodGroup may optionally declare the `schedulingConstraints` field, which TAS interprets while
58-
scheduling all pods within this PodGroup. If constraints are defined in PodGroupTemplate, they will
59-
be copied to referencing PodGroups.
60-
61-
The API currently supports topology constraints.
59+
As of Kubernetes v1.36, the API supports topology constraints.
6260

6361
{{< note >}}
64-
As of Kubernetes v1.36, you can specify only a single topology constraint in each PodGroup. This
65-
may change in the future.
62+
As of Kubernetes v1.36, you can specify only a single topology constraint in each PodGroup.
6663
{{< /note >}}
6764

6865
### Topology constraint
6966

7067
To define a topology constraint for a PodGroup you need to set a `key`, which corresponds to
71-
a Kubernetes node label, representing the target topology domain (for example,
72-
`topology.kubernetes.io/rack`). The scheduler strictly enforces that all pods within the PodGroup
73-
are placed onto nodes that share the exact same value for this specified label.
68+
a Kubernetes node label, representing the target topology domain (for example, a rack or a zone).
69+
The scheduler strictly enforces that all pods within the PodGroup are placed onto nodes that share
70+
the exact same value for this specified label.
7471

7572
Here is an example of a PodGroup configured with a topology constraint:
7673

@@ -85,86 +82,11 @@ spec:
8582
minCount: 4
8683
schedulingConstraints:
8784
topology:
88-
- key: topology.kubernetes.io/rack
89-
```
90-
91-
## Scheduling framework: extension points used by TAS
92-
93-
TAS algorithm proceeds in three main phases for a given PodGroup:
94-
95-
### Phase 1: Candidate placement generation
96-
97-
Generates candidate *placements* (subsets of nodes, that are theoretically feasible for PodGroup
98-
assignment) based on the PodGroup's scheduling constraints.
99-
100-
This phase executes as extension point: `PlacementGeneratePlugin`.
101-
102-
### Phase 2: Pod-level filtering and feasibility check
103-
104-
Validates each proposed placement to see if all pods can fit. If they can, marks the placement as
105-
feasible.
106-
107-
### Phase 3: Placement scoring and selection
108-
109-
Scores all feasible placements to select the optimal domain for the PodGroup.
110-
111-
This phase executes as extension point: `PlacementScorePlugin`.
112-
113-
114-
## Scheduling framework: TAS plugin configuration
115-
116-
The scheduler includes new and extended in-tree plugins that implement the TAS extension points:
117-
118-
* `TopologyPlacement`: Implements the `PlacementGeneratePlugin` interface. It generates candidate
119-
placements by grouping nodes based on the distinct values of the requested topology `key`.
120-
121-
* `NodeResourcesFit`: Extended to implement the `PlacementScorePlugin` interface. Following
122-
similar logic to standard pod bin-packing, it scores placements based on the allocation ratio
123-
across all nodes within the placement. By default, it uses the `MostAllocated` strategy to maximize
124-
resource utilization and fill in smaller "holes" within a placement, and it inherits resource
125-
weights from the standard pod-by-pod plugin settings.
126-
127-
* `PodGroupPodsCount`: Implements the `PlacementScorePlugin` interface. It scores candidate
128-
placements based on the total number of pods in the PodGroup that you can successfully schedule.
129-
130-
### Customizing plugin weights and strategies
131-
132-
By default, the `NodeResourcesFit` and `PodGroupPodsCount` plugins are configured with equal
133-
weights (both default to 1) to maintain a good balance between bin-packing logic and scheduling as
134-
many pods as possible.
135-
136-
You can adjust these weights or change the default scoring strategy in your
137-
KubeSchedulerConfiguration. Here is an example snippet showing how to change the weights for both
138-
plugins, and how to override the `NodeResourcesFit` placement scoring strategy (for example,
139-
changing it from MostAllocated to LeastAllocated):
140-
141-
```yaml
142-
apiVersion: kubescheduler.config.k8s.io/v1
143-
kind: KubeSchedulerConfiguration
144-
profiles:
145-
- schedulerName: default-scheduler
146-
plugins:
147-
score:
148-
enabled:
149-
# 1) Change the default weights of the placement score plugins
150-
- name: NodeResourcesFit
151-
weight: 2
152-
- name: PodGroupPodsCount
153-
weight: 5
154-
pluginConfig:
155-
- name: NodeResourcesFit
156-
args:
157-
# 2) Change the placement scoring strategy and resource weights
158-
placementScoringStrategy:
159-
type: LeastAllocated
160-
resources:
161-
- name: cpu
162-
weight: 1
163-
- name: memory
164-
weight: 1
85+
- key: topology.example.com/rack
16586
```
16687
16788
## {{% heading "whatsnext" %}}
16889
16990
* Learn about [pod group policies](/docs/concepts/workloads/workload-api/policies/).
91+
* Learn about [plugins related Topology-aware Scheduling](/docs/concepts/scheduling-eviction/topology-aware-scheduling/)
17092
* Read about [gang scheduling](/docs/concepts/scheduling-eviction/gang-scheduling/) algorithm.

content/en/docs/reference/scheduling/config.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ extension points:
5656
1. `queueSort`: These plugins provide an ordering function that is used to
5757
sort pending Pods in the scheduling queue. Exactly one queue sort plugin
5858
may be enabled at a time.
59+
1. `placementGenerate`: These plugins generate potential placements (sets of
60+
nodes) where a considered PodGroup could be scheduled. This extension point
61+
is only applicable to PodGroup scheduling and requires Workload scheduling
62+
to be enabled.
63+
1. `placementScore`: These plugins score the placements proposed by
64+
`placementGenerate`, to pick the optimal placement for the considered
65+
PodGroup.
5966
1. `preFilter`: These plugins are used to pre-process or check information
6067
about a Pod or the cluster before filtering. They can mark a pod as
6168
unschedulable.
@@ -132,10 +139,13 @@ extension points:
132139
- `NodeUnschedulable`: Filters out nodes that have `.spec.unschedulable` set to
133140
true.
134141
Extension points: `filter`.
135-
- `NodeResourcesFit`: Checks if the node has all the resources that the Pod is
136-
requesting. The score can use one of three strategies: `LeastAllocated`
137-
(default), `MostAllocated` and `RequestedToCapacityRatio`.
138-
Extension points: `preFilter`, `filter`, `score`.
142+
- `NodeResourcesFit`: For pod-by-pod scheduling checks if the node has all
143+
the resources that the Pod is requesting. The score can use one of three
144+
strategies: `LeastAllocated` (default), `MostAllocated` and
145+
`RequestedToCapacityRatio`.
146+
For PodGroup scheduling calculates the resource utilization in the entire evaluated placement.
147+
The score uses the `MostAllocated` strategy.
148+
Extension points: `preFilter`, `filter`, `score`, `placementScore`.
139149
- `NodeResourcesBalancedAllocation`: Favors nodes that would obtain a more
140150
balanced resource usage if the Pod is scheduled there.
141151
Extension points: `score`.
@@ -175,6 +185,12 @@ extension points:
175185
Extension points: `bind`.
176186
- `DefaultPreemption`: Provides the default preemption mechanism.
177187
Extension points: `postFilter`.
188+
- `TopologyPlacement`: Provides the default placement generation mechanism for PodGroup's topology
189+
constraints.
190+
Extension points: `placementGenerate`.
191+
- `PodGroupPodsCount`: Provides the placement scoring algorithm based on the number of pods that
192+
can be scheduled in the given placement.
193+
Extension points: `placementScore`.
178194

179195
You can also enable the following plugins, through the component config APIs,
180196
that are not enabled by default:

0 commit comments

Comments
 (0)