-
Notifications
You must be signed in to change notification settings - Fork 337
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 node cpu amplification
Signed-off-by: Zach Zhu <[email protected]>
- Loading branch information
Showing
18 changed files
with
1,904 additions
and
7 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
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
30 changes: 30 additions & 0 deletions
30
pkg/scheduler/apis/config/v1beta2/zz_generated.conversion.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
pkg/scheduler/apis/config/v1beta2/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
pkg/scheduler/plugins/nodecpuamplification/least_allocated.go
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,57 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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 nodecpuamplification | ||
|
||
import ( | ||
"k8s.io/kubernetes/pkg/scheduler/framework" | ||
) | ||
|
||
// leastResourceScorer favors nodes with fewer requested resources. | ||
// It calculates the percentage of memory, CPU and other resources requested by pods scheduled on the node, and | ||
// prioritizes based on the minimum of the average of the fraction of requested to capacity. | ||
// | ||
// Details: | ||
// (cpu((capacity-requested)*MaxNodeScore*cpuWeight/capacity) + memory((capacity-requested)*MaxNodeScore*memoryWeight/capacity) + ...)/weightSum | ||
func leastResourceScorer(resToWeightMap resourceToWeightMap) func(requested, allocatable resourceToValueMap) int64 { | ||
return func(requested, allocatable resourceToValueMap) int64 { | ||
var nodeScore, weightSum int64 | ||
for resource := range requested { | ||
weight := resToWeightMap[resource] | ||
resourceScore := leastRequestedScore(requested[resource], allocatable[resource]) | ||
nodeScore += resourceScore * weight | ||
weightSum += weight | ||
} | ||
if weightSum == 0 { | ||
return 0 | ||
} | ||
return nodeScore / weightSum | ||
} | ||
} | ||
|
||
// The unused capacity is calculated on a scale of 0-MaxNodeScore | ||
// 0 being the lowest priority and `MaxNodeScore` being the highest. | ||
// The more unused resources the higher the score is. | ||
func leastRequestedScore(requested, capacity int64) int64 { | ||
if capacity == 0 { | ||
return 0 | ||
} | ||
if requested > capacity { | ||
return 0 | ||
} | ||
|
||
return ((capacity - requested) * framework.MaxNodeScore) / capacity | ||
} |
Oops, something went wrong.