Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactorize EDL controller and autoscaler #579

Merged
merged 13 commits into from
Feb 5, 2018
27 changes: 8 additions & 19 deletions go/cmd/edl/edl.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package main

import (
"context"
"flag"

log "github.com/inconshreveable/log15"
"github.com/wangkuiyi/candy"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand All @@ -21,9 +21,7 @@ func main() {
flag.Parse()

lvl, err := log.LvlFromString(*logLevel)
if err != nil {
panic(err)
}
candy.Must(err)

log.Root().SetHandler(
log.LvlFilterHandler(lvl, log.CallerStackHandler("%+v", log.StderrHandler)),
Expand All @@ -36,27 +34,18 @@ func main() {
} else {
cfg, err = rest.InClusterConfig()
}
if err != nil {
panic(err)
}
candy.Must(err)

// setup some optional configuration
edlresource.RegisterTrainingJob(cfg)
edlresource.RegisterResource(cfg, &edlresource.TrainingJob{}, &edlresource.TrainingJobList{})

clientset, err := kubernetes.NewForConfig(cfg)
if err != nil {
panic(err)
}
candy.Must(err)

client, err := rest.RESTClientFor(cfg)
if err != nil {
panic(err)
}
candy.Must(err)

controller, err := edl.New(client, clientset, *maxLoadDesired)
if err != nil {
panic(err)
}
candy.Must(err)

controller.Run(context.Background())
controller.Run()
}
Loading