forked from koordinator-sh/koordinator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
koord-scheduler: support load-aware scheduling
The scheduling plugin filters abnormal nodes and scores them according to resource usage. The plugin extends the Filter/Score/Reserve/Unreserve extension points defined in the Kubernetes scheduling framework. FYI: docs/proposals/scheduling/20220510-load-aware-scheduling.md Fix koordinator-sh#95 Signed-off-by: Tao Li <joseph.t.lee@outlook.com>
- Loading branch information
Showing
36 changed files
with
4,121 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package extension | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
const ( | ||
// AnnotationCustomUsageThresholds represents the user-defined resource utilization threshold. | ||
// For specific value definitions, see CustomUsageThresholds | ||
AnnotationCustomUsageThresholds = "scheduling.koordinator.sh/usage-thresholds" | ||
) | ||
|
||
// CustomUsageThresholds supports user-defined node resource utilization thresholds. | ||
type CustomUsageThresholds struct { | ||
UsageThresholds map[corev1.ResourceName]int64 `json:"usageThresholds,omitempty"` | ||
} | ||
|
||
func GetCustomUsageThresholds(node *corev1.Node) (*CustomUsageThresholds, error) { | ||
usageThresholds := &CustomUsageThresholds{} | ||
data, ok := node.Annotations[AnnotationCustomUsageThresholds] | ||
if !ok { | ||
return usageThresholds, nil | ||
} | ||
err := json.Unmarshal([]byte(data), usageThresholds) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return usageThresholds, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package config | ||
|
||
import ( | ||
schedulerappconfig "k8s.io/kubernetes/cmd/kube-scheduler/app/config" | ||
|
||
koordinatorclientset "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned" | ||
koordinatorinformers "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions" | ||
) | ||
|
||
// Config has all the context to run a Scheduler | ||
type Config struct { | ||
*schedulerappconfig.Config | ||
KoordinatorClient koordinatorclientset.Interface | ||
KoordinatorSharedInformerFactory koordinatorinformers.SharedInformerFactory | ||
} | ||
|
||
type completedConfig struct { | ||
*Config | ||
} | ||
|
||
// CompletedConfig same as Config, just to swap private object. | ||
type CompletedConfig struct { | ||
// Embed a private pointer that cannot be instantiated outside of this package. | ||
*completedConfig | ||
} | ||
|
||
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. | ||
func (c *Config) Complete() CompletedConfig { | ||
c.Config.Complete() | ||
cc := completedConfig{c} | ||
return CompletedConfig{&cc} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package options | ||
|
||
import ( | ||
scheduleroptions "k8s.io/kubernetes/cmd/kube-scheduler/app/options" | ||
|
||
schedulerappconfig "github.com/koordinator-sh/koordinator/cmd/koord-scheduler/app/config" | ||
koordinatorclientset "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned" | ||
koordinatorinformers "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions" | ||
) | ||
|
||
// Options has all the params needed to run a Scheduler | ||
type Options struct { | ||
*scheduleroptions.Options | ||
} | ||
|
||
// NewOptions returns default scheduler app options. | ||
func NewOptions() *Options { | ||
return &Options{ | ||
Options: scheduleroptions.NewOptions(), | ||
} | ||
} | ||
|
||
// Config return a scheduler config object | ||
func (o *Options) Config() (*schedulerappconfig.Config, error) { | ||
config, err := o.Options.Config() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
koordinatorClient, err := koordinatorclientset.NewForConfig(config.KubeConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
koordinatorSharedInformerFactory := koordinatorinformers.NewSharedInformerFactoryWithOptions(koordinatorClient, 0) | ||
|
||
return &schedulerappconfig.Config{ | ||
Config: config, | ||
KoordinatorClient: koordinatorClient, | ||
KoordinatorSharedInformerFactory: koordinatorSharedInformerFactory, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
GOPATH=`go env GOPATH` | ||
export GOPATH | ||
|
||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[@]}")/.. | ||
|
||
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} | ||
|
||
bash "${CODEGEN_PKG}"/generate-internal-groups.sh \ | ||
"deepcopy,conversion,defaulter" \ | ||
github.com/koordinator-sh/koordinator/pkg/scheduler/apis/generated \ | ||
github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ | ||
github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ | ||
"config:v1beta2" \ | ||
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
reviewers: | ||
- eahydra | ||
- allwmh | ||
- zhaoxianyang385 |
Oops, something went wrong.