Skip to content

Commit

Permalink
feat: add noderesourcefitplus and scarceresourceavoidance scheduler p…
Browse files Browse the repository at this point in the history
…lugis

Signed-off-by: LY-today <[email protected]>
  • Loading branch information
LY-today committed Dec 23, 2024
1 parent a62dd49 commit 507a5b5
Show file tree
Hide file tree
Showing 12 changed files with 1,192 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cmd/koord-scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import (
"github.com/koordinator-sh/koordinator/pkg/scheduler/plugins/elasticquota"
"github.com/koordinator-sh/koordinator/pkg/scheduler/plugins/loadaware"
"github.com/koordinator-sh/koordinator/pkg/scheduler/plugins/nodenumaresource"
noderesourcesfitplus "github.com/koordinator-sh/koordinator/pkg/scheduler/plugins/noderesourcefitplus"
"github.com/koordinator-sh/koordinator/pkg/scheduler/plugins/reservation"
"github.com/koordinator-sh/koordinator/pkg/scheduler/plugins/scarceresourceavoidance"

// Ensure metric package is initialized
_ "k8s.io/component-base/metrics/prometheus/clientgo"
Expand All @@ -40,13 +42,15 @@ import (
)

var koordinatorPlugins = map[string]frameworkruntime.PluginFactory{
loadaware.Name: loadaware.New,
nodenumaresource.Name: nodenumaresource.New,
reservation.Name: reservation.New,
coscheduling.Name: coscheduling.New,
deviceshare.Name: deviceshare.New,
elasticquota.Name: elasticquota.New,
defaultprebind.Name: defaultprebind.New,
loadaware.Name: loadaware.New,
nodenumaresource.Name: nodenumaresource.New,
reservation.Name: reservation.New,
coscheduling.Name: coscheduling.New,
deviceshare.Name: deviceshare.New,
elasticquota.Name: elasticquota.New,
defaultprebind.Name: defaultprebind.New,
noderesourcesfitplus.Name: noderesourcesfitplus.New,
scarceresourceavoidance.Name: scarceresourceavoidance.New,
}

func flatten(plugins map[string]frameworkruntime.PluginFactory) []app.Option {
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/apis/config/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ElasticQuotaArgs{},
&CoschedulingArgs{},
&DeviceShareArgs{},
&NodeResourcesFitPlusArgs{},
&ScarceResourceAvoidanceArgs{},
)
return nil
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/scheduler/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package config
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
schedconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"

"github.com/koordinator-sh/koordinator/apis/extension"
v1 "k8s.io/api/core/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -237,3 +239,24 @@ type DeviceShareArgs struct {
// DisableDeviceNUMATopologyAlignment indicates device don't need to align with other resources' numa topology
DisableDeviceNUMATopologyAlignment bool
}

// +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
}

// +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
}

type ResourcesType struct {
Type config.ScoringStrategyType
Weight int64
}
2 changes: 2 additions & 0 deletions pkg/scheduler/apis/config/v1beta3/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ElasticQuotaArgs{},
&CoschedulingArgs{},
&DeviceShareArgs{},
&NodeResourcesFitPlusArgs{},
&ScarceResourceAvoidanceArgs{},
)
return nil
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/scheduler/apis/config/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
schedconfigv1beta3 "k8s.io/kube-scheduler/config/v1beta3"

"github.com/koordinator-sh/koordinator/apis/extension"
v1 "k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -232,3 +234,24 @@ type DeviceShareArgs struct {
// DisableDeviceNUMATopologyAlignment indicates device don't need to align with other resources' numa topology
DisableDeviceNUMATopologyAlignment bool `json:"disableDeviceNUMATopologyAlignment,omitempty"`
}

// +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 config.ScoringStrategyType `json:"type"`
Weight int64 `json:"weight"`
}
92 changes: 92 additions & 0 deletions pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go

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

78 changes: 78 additions & 0 deletions pkg/scheduler/apis/config/v1beta3/zz_generated.deepcopy.go

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

Loading

0 comments on commit 507a5b5

Please sign in to comment.