forked from IBM/kube-safe-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
safe.go
56 lines (45 loc) · 1.33 KB
/
safe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build safe all
package main
import (
v1 "k8s.io/api/core/v1"
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
safe "kube-safe-scheduler/safe"
)
// Initialize agent
func init() {
InitMain()
// add agent predicates
AddRouterPredicate(safeOverloadPredicate)
// add agent priority functions
AddRouterPriority(safeBalancePriority)
AddRouterPriority(safeOverloadPriority)
}
/**
* Define safe overload predicate
*/
// safeOverloadPredicate : safe node overload predicate
var safeOverloadPredicate = Predicate{
Name: safe.PredicateSafeOverloadName,
Func: func(pod v1.Pod, node v1.Node) (bool, error) {
return safe.PredicateFunc(pod, node)
},
}
/**
* Define safe priority functions
*/
// safeBalancePriority : safe balancing across cluster by
// attempting to equalize (mu + sigma) of all nodes,
// i.e. spread onto node with least value of (mu + sigma)
var safeBalancePriority = Prioritize{
Name: safe.PrioritySafeBalanceName,
Func: func(pod v1.Pod, nodes []v1.Node) (*schedulerapi.HostPriorityList, error) {
return safe.PriorityFunc(pod, nodes, true)
},
}
// safeOverloadPriority : safe node overload priority function
var safeOverloadPriority = Prioritize{
Name: safe.PrioritySafeOverloadName,
Func: func(pod v1.Pod, nodes []v1.Node) (*schedulerapi.HostPriorityList, error) {
return safe.PriorityFunc(pod, nodes, false)
},
}