forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flags.go
57 lines (47 loc) · 1.63 KB
/
flags.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
57
package kubelet
import (
"path"
"github.com/golang/glog"
"github.com/openshift/origin/pkg/oc/clusterup/docker/dockerhelper"
"github.com/openshift/origin/pkg/oc/clusterup/docker/run"
"github.com/openshift/origin/pkg/oc/lib/errors"
)
type KubeletStartFlags struct {
// ContainerBinds is a list of local/path:image/path pairs
ContainerBinds []string
// NodeImage is the docker image for openshift start node and the kubelet
NodeImage string
Environment []string
UseSharedVolume bool
}
func NewKubeletStartFlags() *KubeletStartFlags {
return &KubeletStartFlags{}
}
// MakeKubeletFlags returns the flags to start the kubelet
func (opt KubeletStartFlags) MakeKubeletFlags(dockerClient dockerhelper.Interface, basedir string) (string, error) {
componentName := "create-kubelet-flags"
imageRunHelper := run.NewRunHelper(dockerhelper.NewHelper(dockerClient)).New()
glog.Infof("Running %q", componentName)
binds := append(opt.ContainerBinds)
env := append(opt.Environment)
if opt.UseSharedVolume {
env = append(env, "OPENSHIFT_CONTAINERIZED=false")
}
createFlagsCmd := []string{
"--config=/var/lib/origin/openshift.local.config/node/node-config.yaml",
}
_, stdout, _, rc, err := imageRunHelper.Image(opt.NodeImage).
DiscardContainer().
Bind(binds...).
Env(env...).
SaveContainerLogs(componentName, path.Join(basedir, "logs")).
Entrypoint("openshift-node-config").
Command(createFlagsCmd...).Output()
if err != nil {
return "", errors.NewError("could not run %q: %v", componentName, err).WithCause(err)
}
if rc != 0 {
return "", errors.NewError("could not run %q: rc=%d", componentName, rc)
}
return stdout, nil
}