mirror of https://github.com/k3s-io/k3s
Move run logic into package
parent
65d6280936
commit
e74ac01a62
|
@ -29,7 +29,6 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,7 +52,6 @@ func main() {
|
||||||
Host: "http://" + *master,
|
Host: "http://" + *master,
|
||||||
})
|
})
|
||||||
|
|
||||||
go util.Forever(func() { controllerManager.Synchronize() }, 20*time.Second)
|
controllerManager.Run(10 * time.Second)
|
||||||
go util.Forever(func() { controllerManager.WatchControllers() }, 20*time.Second)
|
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,13 @@ func MakeReplicationManager(etcdClient *etcd.Client, kubeClient client.ClientInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rm *ReplicationManager) WatchControllers() {
|
// Begin watching and syncing.
|
||||||
|
func (rm *ReplicationManager) Run(period time.Duration) {
|
||||||
|
go util.Forever(func() { rm.synchronize() }, period)
|
||||||
|
go util.Forever(func() { rm.watchControllers() }, period)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rm *ReplicationManager) watchControllers() {
|
||||||
watchChannel := make(chan *etcd.Response)
|
watchChannel := make(chan *etcd.Response)
|
||||||
go func() {
|
go func() {
|
||||||
defer util.HandleCrash()
|
defer util.HandleCrash()
|
||||||
|
@ -166,8 +172,7 @@ func (rm *ReplicationManager) syncReplicationController(controllerSpec api.Repli
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rm *ReplicationManager) Synchronize() {
|
func (rm *ReplicationManager) synchronize() {
|
||||||
for {
|
|
||||||
response, err := rm.etcdClient.Get("/registry/controllers", false, false)
|
response, err := rm.etcdClient.Get("/registry/controllers", false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Synchronization error %#v", err)
|
log.Printf("Synchronization error %#v", err)
|
||||||
|
@ -194,6 +199,4 @@ func (rm *ReplicationManager) Synchronize() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue