You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/scheduling-eviction/resource-bin-packing.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ weight: 80
10
10
11
11
<!-- overview -->
12
12
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
+
13
17
In the [scheduling-plugin](/docs/reference/scheduling/config/#scheduling-plugins)`NodeResourcesFit` of kube-scheduler, there are two
14
18
scoring strategies that support the bin packing of resources: `MostAllocated` and `RequestedToCapacityRatio`.
*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/).
Copy file name to clipboardExpand all lines: content/en/docs/concepts/workloads/workload-api/topology-aware-scheduling.md
+13-91Lines changed: 13 additions & 91 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,22 +10,22 @@ weight: 10
10
10
*Topology-Aware Scheduling* (TAS) is a feature of the Workload API that optimizes the placement of
11
11
pods within the cluster.
12
12
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,
14
14
such as a single server rack or zone. This minimizes inter-pod communication latency and prevents
15
15
workload fragmentation across the cluster infrastructure.
16
16
17
17
## Topology-aware scheduling with gang scheduling policy
18
18
19
19
When applied to PodGroups with `gang` scheduling policy, TAS simulates the potential assignment
20
20
(*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.
22
22
If no feasible placement is found, the entire PodGroup becomes unschedulable.
23
23
24
24
This is the recommended approach for workloads like distributed AI and ML training that strictly
25
25
require proximity to minimize inter-pod communication latency.
26
26
27
27
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
29
29
domain where the existing pods currently reside. If that specific domain lacks sufficient capacity
30
30
for the new pods, the pods will remain pending - even if it means that less than `minCount` pods
31
31
are scheduled at this point.
@@ -52,25 +52,22 @@ insufficient capacity (in which case the new pods will remain pending).
52
52
53
53
## API configuration: scheduling constraints
54
54
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.
56
58
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.
62
60
63
61
{{< 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.
66
63
{{< /note >}}
67
64
68
65
### Topology constraint
69
66
70
67
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.
74
71
75
72
Here is an example of a PodGroup configured with a topology constraint:
76
73
@@ -85,86 +82,11 @@ spec:
85
82
minCount: 4
86
83
schedulingConstraints:
87
84
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
165
86
```
166
87
167
88
## {{% heading "whatsnext" %}}
168
89
169
90
* 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/)
170
92
* Read about [gang scheduling](/docs/concepts/scheduling-eviction/gang-scheduling/) algorithm.
0 commit comments