Skip to content

Commit ac200da

Browse files
committed
add loadaware scheduler plugin args
1 parent 77c1caf commit ac200da

File tree

12 files changed

+472
-1
lines changed

12 files changed

+472
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
k8s.io/kubelet v0.24.6
1515
k8s.io/kubernetes v1.24.6
1616
k8s.io/metrics v0.24.6
17+
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
1718
sigs.k8s.io/yaml v1.2.0
1819
)
1920

@@ -59,7 +60,6 @@ require (
5960
k8s.io/component-base v0.24.6 // indirect
6061
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 // indirect
6162
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
62-
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
6363
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
6464
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
6565
)

pkg/apis/scheduling/config/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3535
&QoSAwareNodeResourcesFitArgs{},
3636
&QoSAwareNodeResourcesBalancedAllocationArgs{},
3737
&NodeResourceTopologyArgs{},
38+
&LoadAwareArgs{},
3839
)
3940
return nil
4041
}

pkg/apis/scheduling/config/types.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package config
1616

1717
import (
18+
corev1 "k8s.io/api/core/v1"
1819
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1920
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
2021

@@ -85,3 +86,37 @@ type ScoringStrategy struct {
8586
// Arguments specific to RequestedToCapacityRatio strategy.
8687
ReclaimedRequestedToCapacityRatio *kubeschedulerconfig.RequestedToCapacityRatioParam `json:"reclaimedRequestedToCapacityRatio,omitempty"`
8788
}
89+
90+
// IndicatorType indicator participate in calculate score
91+
type IndicatorType string
92+
93+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
94+
95+
// LoadAwareArgs holds arguments used to configure the LoadAwareScheduling plugin.
96+
type LoadAwareArgs struct {
97+
metav1.TypeMeta
98+
99+
EnablePortrait *bool `json:"enablePortrait,omitempty"`
100+
PodAnnotationLoadAwareEnable *string `json:"podAnnotationLoadAwareEnable,omitempty"`
101+
// FilterExpiredNodeMetrics indicates whether to filter nodes where fails to update NPD.
102+
FilterExpiredNodeMetrics *bool `json:"filterExpiredNodeMetrics,omitempty"`
103+
// NodeMetricsExpiredSeconds indicates the NodeMetrics in NPD expiration in seconds.
104+
// When NodeMetrics expired, the node is considered abnormal.
105+
// default 5 minute
106+
NodeMetricsExpiredSeconds *int64 `json:"NodeMetricsExpiredSeconds,omitempty"`
107+
// ResourceToWeightMap contains resource name and weight.
108+
ResourceToWeightMap map[corev1.ResourceName]int64 `json:"resourceToWeightMap,omitempty"`
109+
// ResourceToThresholdMap contains resource name and threshold. Node can not be scheduled
110+
// if usage of it is more than threshold.
111+
ResourceToThresholdMap map[corev1.ResourceName]int64 `json:"resourceToThresholdMap,omitempty"`
112+
// ResourceToScalingFactorMap contains resource name and scaling factor, which are used to estimate pod usage
113+
// if usage of pod is not exists in node monitor.
114+
ResourceToScalingFactorMap map[corev1.ResourceName]int64 `json:"resourceToScalingFactorMap,omitempty"`
115+
// ResourceToTargetMap contains resource name and node usage target which are used in loadAware score
116+
ResourceToTargetMap map[corev1.ResourceName]int64 `json:"resourceToTargetMap,omitempty"`
117+
// CalculateIndicatorWeight indicates the participates in calculate indicator weight
118+
// The default avg_15min 30, max_1hour 30, max_1day 40
119+
CalculateIndicatorWeight map[IndicatorType]int64 `json:"calculateIndicatorWeight,omitempty"`
120+
121+
KubeConfigPath string `json:"kubeConfigPath,omitempty"`
122+
}

pkg/apis/scheduling/config/v1beta3/defaults.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
v1 "k8s.io/api/core/v1"
2121
"k8s.io/kube-scheduler/config/v1beta3"
22+
"k8s.io/utils/pointer"
2223

2324
"github.com/kubewharf/katalyst-api/pkg/consts"
2425
)
@@ -35,6 +36,33 @@ var defaultReclaimedResourceSpec = []v1beta3.ResourceSpec{
3536

3637
var defaultAlignedResourceSpec = []string{v1.ResourceCPU.String(), v1.ResourceMemory.String()}
3738

39+
var (
40+
defaultNodeMonitorExpiredSeconds int64 = 180
41+
defaultResourceToWeightMap = map[v1.ResourceName]int64{
42+
v1.ResourceCPU: 1,
43+
v1.ResourceMemory: 1,
44+
}
45+
46+
defaultResourceToThresholdMap = map[v1.ResourceName]int64{
47+
v1.ResourceCPU: 70, // 70%
48+
v1.ResourceMemory: 95, // 95%
49+
}
50+
51+
defaultResourceToScalingFactorMap = map[v1.ResourceName]int64{
52+
v1.ResourceCPU: 85, // 85%
53+
v1.ResourceMemory: 70, // 70%
54+
}
55+
defaultCalculateIndicatorWeight = map[IndicatorType]int64{
56+
consts.Usage15MinAvgKey: 30, //30%
57+
consts.Usage1HourMaxKey: 30, //30%
58+
consts.Usage1DayMaxKey: 40, //40%
59+
}
60+
defaultResourceToTargetMap = map[v1.ResourceName]int64{
61+
v1.ResourceCPU: 50,
62+
v1.ResourceMemory: 70,
63+
}
64+
)
65+
3866
// SetDefaults_QoSAwareNodeResourcesFitArgs sets the default parameters for QoSAwareNodeResourcesFit plugin.
3967
func SetDefaults_QoSAwareNodeResourcesFitArgs(obj *QoSAwareNodeResourcesFitArgs) {
4068
if obj.ScoringStrategy == nil {
@@ -107,3 +135,30 @@ func SetDefaults_NodeResourceTopologyArgs(obj *NodeResourceTopologyArgs) {
107135
obj.ResourcePluginPolicy = consts.ResourcePluginPolicyNameDynamic
108136
}
109137
}
138+
139+
func SetDefaults_LoadAwareArgs(obj *LoadAwareArgs) {
140+
if obj.FilterExpiredNodeMetrics == nil {
141+
obj.FilterExpiredNodeMetrics = pointer.BoolPtr(true)
142+
}
143+
if obj.NodeMetricsExpiredSeconds == nil {
144+
obj.NodeMetricsExpiredSeconds = pointer.Int64Ptr(defaultNodeMonitorExpiredSeconds)
145+
}
146+
if len(obj.ResourceToWeightMap) == 0 {
147+
obj.ResourceToWeightMap = defaultResourceToWeightMap
148+
}
149+
if len(obj.ResourceToThresholdMap) == 0 {
150+
obj.ResourceToThresholdMap = defaultResourceToThresholdMap
151+
}
152+
if len(obj.ResourceToScalingFactorMap) == 0 {
153+
obj.ResourceToScalingFactorMap = defaultResourceToScalingFactorMap
154+
}
155+
if len(obj.CalculateIndicatorWeight) == 0 {
156+
obj.CalculateIndicatorWeight = defaultCalculateIndicatorWeight
157+
}
158+
if len(obj.ResourceToTargetMap) == 0 {
159+
obj.ResourceToTargetMap = defaultResourceToTargetMap
160+
}
161+
if obj.EnablePortrait == nil {
162+
obj.EnablePortrait = pointer.Bool(false)
163+
}
164+
}

pkg/apis/scheduling/config/v1beta3/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3535
&QoSAwareNodeResourcesFitArgs{},
3636
&QoSAwareNodeResourcesBalancedAllocationArgs{},
3737
&NodeResourceTopologyArgs{},
38+
&LoadAwareArgs{},
3839
)
3940
return nil
4041
}

pkg/apis/scheduling/config/v1beta3/types.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package v1beta3
1616

1717
import (
18+
corev1 "k8s.io/api/core/v1"
1819
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1920
"k8s.io/kube-scheduler/config/v1beta3"
2021

@@ -85,3 +86,37 @@ type NodeResourceTopologyArgs struct {
8586
// ResourcePluginPolicy are QRMPlugin resource policy to allocate topology resource for containers.
8687
ResourcePluginPolicy consts.ResourcePluginPolicyName `json:"resourcePluginPolicy,omitempty"`
8788
}
89+
90+
// IndicatorType indicator participate in calculate score
91+
type IndicatorType string
92+
93+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
94+
95+
// LoadAwareArgs holds arguments used to configure the LoadAwareScheduling plugin.
96+
type LoadAwareArgs struct {
97+
metav1.TypeMeta
98+
99+
EnablePortrait *bool `json:"enablePortrait,omitempty"`
100+
PodAnnotationLoadAwareEnable *string `json:"podAnnotationLoadAwareEnable,omitempty"`
101+
// FilterExpiredNodeMetrics indicates whether to filter nodes where fails to update NPD.
102+
FilterExpiredNodeMetrics *bool `json:"filterExpiredNodeMetrics,omitempty"`
103+
// NodeMetricsExpiredSeconds indicates the NodeMetrics in NPD expiration in seconds.
104+
// When NodeMetrics expired, the node is considered abnormal.
105+
// default 5 minute
106+
NodeMetricsExpiredSeconds *int64 `json:"NodeMetricsExpiredSeconds,omitempty"`
107+
// ResourceToWeightMap contains resource name and weight.
108+
ResourceToWeightMap map[corev1.ResourceName]int64 `json:"resourceToWeightMap,omitempty"`
109+
// ResourceToThresholdMap contains resource name and threshold. Node can not be scheduled
110+
// if usage of it is more than threshold.
111+
ResourceToThresholdMap map[corev1.ResourceName]int64 `json:"resourceToThresholdMap,omitempty"`
112+
// ResourceToScalingFactorMap contains resource name and scaling factor, which are used to estimate pod usage
113+
// if usage of pod is not exists in node monitor.
114+
ResourceToScalingFactorMap map[corev1.ResourceName]int64 `json:"resourceToScalingFactorMap,omitempty"`
115+
// ResourceToTargetMap contains resource name and node usage target which are used in loadAware score
116+
ResourceToTargetMap map[corev1.ResourceName]int64 `json:"resourceToTargetMap,omitempty"`
117+
// CalculateIndicatorWeight indicates the participates in calculate indicator weight
118+
// The default avg_15min 30, max_1hour 30, max_1day 40
119+
CalculateIndicatorWeight map[IndicatorType]int64 `json:"calculateIndicatorWeight,omitempty"`
120+
121+
KubeConfigPath string `json:"kubeConfigPath,omitempty"`
122+
}

pkg/apis/scheduling/config/v1beta3/zz_generated.conversion.go

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

pkg/apis/scheduling/config/v1beta3/zz_generated.deepcopy.go

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

pkg/apis/scheduling/config/v1beta3/zz_generated.defaults.go

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

0 commit comments

Comments
 (0)