mirror of https://github.com/kubernetes/kops.git
Merge pull request #54 from justinsb/upup_protokube
Use protokube with upup
This commit is contained in:
commit
062d2ece96
|
@ -24,6 +24,9 @@ func main() {
|
|||
// target = "dryrun"
|
||||
//}
|
||||
|
||||
master := false
|
||||
flag.BoolVar(&master, "master", false, "Act as master")
|
||||
|
||||
flag.Set("logtostderr", "true")
|
||||
flag.Parse()
|
||||
|
||||
|
@ -37,7 +40,7 @@ func main() {
|
|||
// glog.Exitf("--conf is required")
|
||||
//}
|
||||
|
||||
kubeboot := protokube.NewKubeBoot(volumes)
|
||||
kubeboot := protokube.NewKubeBoot(master, volumes)
|
||||
err = kubeboot.Bootstrap()
|
||||
if err != nil {
|
||||
glog.Errorf("Error during bootstrap: %q", err)
|
||||
|
|
|
@ -6,11 +6,13 @@ import (
|
|||
)
|
||||
|
||||
type KubeBoot struct {
|
||||
master bool
|
||||
volumes Volumes
|
||||
}
|
||||
|
||||
func NewKubeBoot(volumes Volumes) *KubeBoot {
|
||||
func NewKubeBoot(master bool, volumes Volumes) *KubeBoot {
|
||||
k := &KubeBoot{
|
||||
master: master,
|
||||
volumes: volumes,
|
||||
}
|
||||
return k
|
||||
|
@ -20,11 +22,11 @@ func (k *KubeBoot) Bootstrap() error {
|
|||
for {
|
||||
done, err := k.tryBootstrap()
|
||||
if err != nil {
|
||||
glog.Warningf("error during attempt to acquire master volume (will sleep and retry): %v", err)
|
||||
glog.Warningf("error during attempt to bootstrap (will sleep and retry): %v", err)
|
||||
} else if done {
|
||||
break
|
||||
} else {
|
||||
glog.Infof("unable to acquire master volume; will sleep and retry")
|
||||
glog.Infof("unable to bootstrap; will sleep and retry")
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Minute)
|
||||
|
@ -34,13 +36,20 @@ func (k *KubeBoot) Bootstrap() error {
|
|||
}
|
||||
|
||||
func (k *KubeBoot) tryBootstrap() (bool, error) {
|
||||
mountpoint, err := k.mountMasterVolume()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if k.master {
|
||||
mountpoint, err := k.mountMasterVolume()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
glog.Infof("mounted master on %s", mountpoint)
|
||||
// TODO: Should we set up symlinks here?
|
||||
if mountpoint == "" {
|
||||
glog.Infof("unable to acquire master volume")
|
||||
return false, nil
|
||||
}
|
||||
|
||||
glog.Infof("mounted master on %s", mountpoint)
|
||||
// TODO: Should we set up symlinks here?
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{{ if HasTag "_kubernetes_master" }}
|
||||
DAEMON_ARGS="--master=true"
|
||||
{{ else }}
|
||||
DAEMON_ARGS="--master=false"
|
||||
{{ end }}
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Kubernetes Protokube Service
|
||||
Documentation=https://github.com/kubernetes/kube-deploy/protokube
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/etc/sysconfig/protokube
|
||||
ExecStart=/usr/local/bin/protokube "$DAEMON_ARGS"
|
||||
Restart=always
|
||||
RestartSec=2s
|
||||
StartLimitInterval=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -21,6 +21,8 @@ type Loader struct {
|
|||
|
||||
assets *fi.AssetStore
|
||||
tasks map[string]fi.Task
|
||||
|
||||
tags map[string]struct{}
|
||||
}
|
||||
|
||||
func NewLoader(config *NodeConfig, assets *fi.AssetStore) *Loader {
|
||||
|
@ -41,6 +43,10 @@ func (l *Loader) executeTemplate(key string, d string) (string, error) {
|
|||
funcMap["Base64Encode"] = func(s string) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(s))
|
||||
}
|
||||
funcMap["HasTag"] = func(tag string) bool {
|
||||
_, found := l.tags[tag]
|
||||
return found
|
||||
}
|
||||
t.Funcs(funcMap)
|
||||
|
||||
context := l.config
|
||||
|
@ -71,6 +77,8 @@ func (l *Loader) Build(baseDir string) (map[string]fi.Task, error) {
|
|||
tags[tag] = struct{}{}
|
||||
}
|
||||
|
||||
l.tags = tags
|
||||
|
||||
// First pass: load options
|
||||
tw := &loader.TreeWalker{
|
||||
DefaultHandler: ignoreHandler,
|
||||
|
|
Loading…
Reference in New Issue