-
Notifications
You must be signed in to change notification settings - Fork 14
/
scheduler_restart.go
46 lines (38 loc) · 1000 Bytes
/
scheduler_restart.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
package k8s
import (
"github.com/cybozu-go/cke"
"github.com/cybozu-go/cke/op"
"github.com/cybozu-go/cke/op/common"
)
type schedulerRestartOp struct {
nodes []*cke.Node
cluster string
params cke.ServiceParams
pulled bool
finished bool
}
// SchedulerRestartOp returns an Operator to restart kube-scheduler
func SchedulerRestartOp(nodes []*cke.Node, cluster string, params cke.ServiceParams) cke.Operator {
return &schedulerRestartOp{
nodes: nodes,
cluster: cluster,
params: params,
}
}
func (o *schedulerRestartOp) Name() string {
return "kube-scheduler-restart"
}
func (o *schedulerRestartOp) NextCommand() cke.Commander {
if !o.pulled {
o.pulled = true
return common.ImagePullCommand(o.nodes, cke.HyperkubeImage)
}
if !o.finished {
o.finished = true
return common.RunContainerCommand(o.nodes, op.KubeSchedulerContainerName, cke.HyperkubeImage,
common.WithParams(SchedulerParams()),
common.WithExtra(o.params),
common.WithRestart())
}
return nil
}