-
Notifications
You must be signed in to change notification settings - Fork 15
/
apiserver_restart.go
55 lines (46 loc) · 1.26 KB
/
apiserver_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
47
48
49
50
51
52
53
54
55
package k8s
import (
"github.com/cybozu-go/cke"
"github.com/cybozu-go/cke/op"
"github.com/cybozu-go/cke/op/common"
)
type apiServerRestartOp struct {
nodes []*cke.Node
cps []*cke.Node
serviceSubnet string
params cke.ServiceParams
pulled bool
}
// APIServerRestartOp returns an Operator to restart kube-apiserver
func APIServerRestartOp(nodes, cps []*cke.Node, serviceSubnet string, params cke.ServiceParams) cke.Operator {
return &apiServerRestartOp{
nodes: nodes,
cps: cps,
serviceSubnet: serviceSubnet,
params: params,
}
}
func (o *apiServerRestartOp) Name() string {
return "kube-apiserver-restart"
}
func (o *apiServerRestartOp) NextCommand() cke.Commander {
if !o.pulled {
o.pulled = true
return common.ImagePullCommand(o.nodes, cke.HyperkubeImage)
}
if len(o.nodes) == 0 {
return nil
}
// API server should be restarted one by one.
node := o.nodes[0]
o.nodes = o.nodes[1:]
opts := []string{
"--mount", "type=tmpfs,dst=/run/kubernetes",
}
return common.RunContainerCommand([]*cke.Node{node},
op.KubeAPIServerContainerName, cke.HyperkubeImage,
common.WithOpts(opts),
common.WithParams(APIServerParams(o.cps, node.Address, o.serviceSubnet)),
common.WithExtra(o.params),
common.WithRestart())
}