Skip to content

Commit 1eb9d1f

Browse files
committed
feat: add NodeResourcesFitPlus and ScarceResourceAvoidance plugin
Signed-off-by: LY-today <[email protected]>
1 parent f633dd2 commit 1eb9d1f

File tree

12 files changed

+1031
-0
lines changed

12 files changed

+1031
-0
lines changed

apis/config/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4545
&NetworkOverheadArgs{},
4646
&SySchedArgs{},
4747
&PeaksArgs{},
48+
&NodeResourcesFitPlusArgs{},
49+
&ScarceResourceAvoidanceArgs{},
4850
)
4951
return nil
5052
}

apis/config/types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,24 @@ type PowerModel struct {
298298
// Power = K0 + K1 * e ^(K2 * x) : where x is utilisation
299299
// Idle power of node will be K0 + K1
300300
}
301+
302+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
303+
304+
// ScarceResourceAvoidanceArgs defines the parameters for ScarceResourceAvoidance plugin.
305+
type ScarceResourceAvoidanceArgs struct {
306+
metav1.TypeMeta
307+
Resources []v1.ResourceName `json:"resources,omitempty"`
308+
}
309+
310+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
311+
312+
// NodeResourcesFitPlusArgs defines the parameters for NodeResourcesFitPlus plugin.
313+
type NodeResourcesFitPlusArgs struct {
314+
metav1.TypeMeta
315+
Resources map[v1.ResourceName]ResourcesType `json:"resources"`
316+
}
317+
318+
type ResourcesType struct {
319+
Type schedconfig.ScoringStrategyType `json:"type"`
320+
Weight int64 `json:"weight"`
321+
}

apis/config/zz_generated.deepcopy.go

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/scheduler/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package main
1818

1919
import (
2020
"os"
21+
noderesourcesfitplus "sigs.k8s.io/scheduler-plugins/pkg/noderesourcefitplus"
22+
"sigs.k8s.io/scheduler-plugins/pkg/scarceresourceavoidance"
2123

2224
"k8s.io/component-base/cli"
2325
_ "k8s.io/component-base/metrics/prometheus/clientgo" // for rest client metric registration
@@ -64,6 +66,8 @@ func main() {
6466
// app.WithPlugin(crossnodepreemption.Name, crossnodepreemption.New),
6567
app.WithPlugin(podstate.Name, podstate.New),
6668
app.WithPlugin(qos.Name, qos.New),
69+
app.WithPlugin(noderesourcesfitplus.Name, noderesourcesfitplus.New),
70+
app.WithPlugin(scarceresourceavoidance.Name, scarceresourceavoidance.New),
6771
)
6872

6973
code := cli.Run(command)
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Disk IO Aware Scheduling
2+
3+
<!-- toc -->
4+
- [Summary](#summary)
5+
- [Motivation](#motivation)
6+
- [Design Consideration](#design-consideration)
7+
- [Goals](#goals)
8+
- [Non-Goals](#non-goals)
9+
- [Proposal](#proposal)
10+
- [Design Details](#design-details)
11+
- [NodeResourcesFitPlus](#noderesourcesfitplus)
12+
- [ScarceResourceAvoidance](#scarceresourceavoidance)
13+
- [Test Plan](#test-plan)
14+
- [Graduation Criteria](#graduation-criteria)
15+
- [Alpha](#alpha)
16+
- [Beta](#beta)
17+
- [Implementation History](#implementation-history)
18+
<!-- /toc -->
19+
20+
21+
## Summary
22+
23+
The NodeResourcesFit plug-in of native k8s can only adopt a type of strategy for all resources, such as MostRequestedPriority and LeastRequestedPriority. However, in industrial practice, this design does not apply to some scenarios. For example: In AI scenarios, businesses that apply for GPUs prefer to occupy the entire GPU machine first to prevent GPU fragmentation; businesses that apply for CPU & MEM are prioritized and dispersed to non-GPU machines to prevent excessive consumption of CPU & MEM on GPU machines, resulting in real tasks of applying for GPUs. Pending due to insufficient non-GPU resources
24+
. Therefore, two plugins are extended to solve this common problem.
25+
26+
## Motivation
27+
case:
28+
- GPU tasks take priority over the entire GPU
29+
- CPU&MEM tasks are distributed to the CPU machine first
30+
31+
## Design Consideration
32+
33+
- The solution is more versatile, not limited to AI clusters or CPU clusters, and not limited to common CPU resources or extended GPU resources.
34+
35+
- Different resource policies can be configured for different cluster types and prioritized in the form of weights.
36+
37+
- Easy to expand
38+
39+
### Goals
40+
41+
- Different types of resources can be configured with different strategies to prioritize them in the form of weights
42+
43+
- Prevent pods that have not applied for scarce resources from being scheduled to nodes with scarce resources.
44+
45+
### Non-Goals
46+
47+
- None.
48+
49+
## Proposal
50+
51+
Extend two plug-ins to meet the above needs
52+
53+
- NodeResourcesFitPlus
54+
- ScarceResourceAvoidance
55+
56+
## Design Details
57+
58+
### NodeResourcesFitPlus
59+
60+
config:
61+
```
62+
resources:
63+
nvidia.com/gpu:
64+
type: MostAllocated
65+
weight: 2
66+
cpu:
67+
type: LeastAllocated
68+
weight: 1
69+
memory:
70+
type: LeastAllocated
71+
weight: 1
72+
```
73+
config description:
74+
<p align="center"><img src="images/img1.png" title="Key components" width="600" class="center"/></p>
75+
76+
node score:
77+
```
78+
finalScoreNode = [(weight1 * resource1) + (weight2 * resource2) + … + (weightN* resourceN)] /(weight1+weight2+ … +weightN)
79+
```
80+
81+
### ScarceResourceAvoidance
82+
config:
83+
```
84+
resources:
85+
- nvidia.com/gpu
86+
```
87+
config description:
88+
<p align="center"><img src="images/img2.png" title="Key components" width="600" class="center"/></p>
89+
90+
node score:
91+
```
92+
finalScoreNode = (allocatablesResourcesNum - requestsResourcesNum) * framework.MaxNodeScore / allocatablesResourcesNum
93+
```
94+
95+
### Test Plan
96+
97+
Comprehensive unit tests will be added to ensure that each functionality works as expected. Additionally, detailed integration tests will be implemented to verify that the scheduler plugin and IO Driver interact without any issue.
98+
99+
Finally, a basic e2e test will be included to ensure that all components can work together properly.
100+
101+
### Graduation Criteria
102+
103+
#### Alpha
104+
105+
- Implement the NodeResourcesFitPlus and ScarceResourceAvoidance scheduler plugins
106+
- Provide a reference implementation of the NodeResourcesFitPlus and ScarceResourceAvoidance
107+
- Unit tests and integration test from [Test Plan](#test-plan).
108+
109+
#### Beta
110+
111+
- Add E2E tests.
112+
- Provide beta-level documentation.
113+
114+
## Implementation History
115+
116+
- 2024-12-23: KEP created
Loading
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
title: Node Resource Fit plus Scheduling
2+
kep-number: 624
3+
authors:
4+
- "@LY-today"
5+
owning-sig: sig-scheduling
6+
creation-date: 2024-12-23
7+
last-updated: 2024-12-23

0 commit comments

Comments
 (0)