Skip to content

feat: add NodeResourcesFitPlus and ScarceResourceAvoidance plugin #843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apis/config/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&NetworkOverheadArgs{},
&SySchedArgs{},
&PeaksArgs{},
&NodeResourcesFitPlusArgs{},
&ScarceResourceAvoidanceArgs{},
)
return nil
}
Expand Down
21 changes: 21 additions & 0 deletions apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,24 @@ type PowerModel struct {
// Power = K0 + K1 * e ^(K2 * x) : where x is utilisation
// Idle power of node will be K0 + K1
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ScarceResourceAvoidanceArgs defines the parameters for ScarceResourceAvoidance plugin.
type ScarceResourceAvoidanceArgs struct {
metav1.TypeMeta
Resources []v1.ResourceName `json:"resources,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NodeResourcesFitPlusArgs defines the parameters for NodeResourcesFitPlus plugin.
type NodeResourcesFitPlusArgs struct {
metav1.TypeMeta
Resources map[v1.ResourceName]ResourcesType `json:"resources"`
}

type ResourcesType struct {
Type schedconfig.ScoringStrategyType `json:"type"`
Weight int64 `json:"weight"`
}
63 changes: 63 additions & 0 deletions apis/config/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cmd/scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package main

import (
"os"
noderesourcesfitplus "sigs.k8s.io/scheduler-plugins/pkg/noderesourcefitplus"
"sigs.k8s.io/scheduler-plugins/pkg/scarceresourceavoidance"

"k8s.io/component-base/cli"
_ "k8s.io/component-base/metrics/prometheus/clientgo" // for rest client metric registration
Expand Down Expand Up @@ -64,6 +66,8 @@ func main() {
// app.WithPlugin(crossnodepreemption.Name, crossnodepreemption.New),
app.WithPlugin(podstate.Name, podstate.New),
app.WithPlugin(qos.Name, qos.New),
app.WithPlugin(noderesourcesfitplus.Name, noderesourcesfitplus.New),
app.WithPlugin(scarceresourceavoidance.Name, scarceresourceavoidance.New),
)

code := cli.Run(command)
Expand Down
116 changes: 116 additions & 0 deletions kep/625-node-resource-fit-plus-scoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Disk IO Aware Scheduling
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we separate into two PRs? Wait until the KEPs are merged before reviewing the PRs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that KEP and the two plugins are split into two PRs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


<!-- toc -->
- [Summary](#summary)
- [Motivation](#motivation)
- [Design Consideration](#design-consideration)
- [Goals](#goals)
- [Non-Goals](#non-goals)
- [Proposal](#proposal)
- [Design Details](#design-details)
- [NodeResourcesFitPlus](#noderesourcesfitplus)
- [ScarceResourceAvoidance](#scarceresourceavoidance)
- [Test Plan](#test-plan)
- [Graduation Criteria](#graduation-criteria)
- [Alpha](#alpha)
- [Beta](#beta)
- [Implementation History](#implementation-history)
<!-- /toc -->


## Summary

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
. Therefore, two plugins are extended to solve this common problem.

## Motivation
case:
- GPU tasks take priority over the entire GPU
- CPU&MEM tasks are distributed to the CPU machine first

## Design Consideration

- The solution is more versatile, not limited to AI clusters or CPU clusters, and not limited to common CPU resources or extended GPU resources.

- Different resource policies can be configured for different cluster types and prioritized in the form of weights.

- Easy to expand

### Goals

- Different types of resources can be configured with different strategies to prioritize them in the form of weights

- Prevent pods that have not applied for scarce resources from being scheduled to nodes with scarce resources.

### Non-Goals

- None.

## Proposal

Extend two plug-ins to meet the above needs

- NodeResourcesFitPlus
- ScarceResourceAvoidance

## Design Details

### NodeResourcesFitPlus

config:
```
resources:
nvidia.com/gpu:
type: MostAllocated
weight: 2
cpu:
type: LeastAllocated
weight: 1
memory:
type: LeastAllocated
weight: 1
```
config description:
<p align="center"><img src="images/img1.png" title="Key components" width="600" class="center"/></p>

node score:
```
finalScoreNode = [(weight1 * resource1) + (weight2 * resource2) + … + (weightN* resourceN)] /(weight1+weight2+ … +weightN)
```

### ScarceResourceAvoidance
config:
```
resources:
- nvidia.com/gpu
```
config description:
<p align="center"><img src="images/img2.png" title="Key components" width="600" class="center"/></p>

node score:
```
finalScoreNode = (allocatablesResourcesNum - requestsResourcesNum) * framework.MaxNodeScore / allocatablesResourcesNum
```

### Test Plan

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.

Finally, a basic e2e test will be included to ensure that all components can work together properly.

### Graduation Criteria

#### Alpha

- Implement the NodeResourcesFitPlus and ScarceResourceAvoidance scheduler plugins
- Provide a reference implementation of the NodeResourcesFitPlus and ScarceResourceAvoidance
- Unit tests and integration test from [Test Plan](#test-plan).

#### Beta

- Add E2E tests.
- Provide beta-level documentation.

## Implementation History

- 2024-12-23: KEP created
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions kep/625-node-resource-fit-plus-scoring/kep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Node Resource Fit plus Scheduling
kep-number: 624
authors:
- "@LY-today"
owning-sig: sig-scheduling
creation-date: 2024-12-23
last-updated: 2024-12-23
Loading