-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoflow.go
69 lines (62 loc) · 1.65 KB
/
goflow.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
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"flag"
"goflow/internal/config"
"goflow/internal/dag/metrics"
"goflow/internal/dag/orchestrator"
"goflow/internal/k8s/client"
"goflow/internal/k8s/pod/utils"
"goflow/internal/logs"
"goflow/internal/paths"
"goflow/internal/rest"
"goflow/internal/termination"
"goflow/internal/testutils"
"io/ioutil"
"time"
core "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
var host string
var port int
func main() {
configPath := flag.String(
"path",
paths.GetGoDefaultHomePath(),
"The path to the configuration file",
)
host := flag.String("host", "localhost", "Host IP to serve REST api on")
port := flag.Int("port", 8080, "Port to serve REST API on")
verbosePtr := flag.Bool("V", false, "Verbose logging")
testMode := flag.Bool("T", false, "Uses test mode which leverage a mocked kubernetes client")
flag.Parse()
if !*verbosePtr {
logs.InfoLogger.SetOutput(ioutil.Discard)
}
var orch *orchestrator.Orchestrator
if *testMode {
kubeClient := fake.NewSimpleClientset()
kubeClient.Tracker().Add(&core.Namespace{
ObjectMeta: v1.ObjectMeta{
Name: "default",
},
})
testutils.RegisterContainerStatusesToPods(kubeClient)
config := config.CreateConfig(*configPath)
config.DAGsOn = true
orch = orchestrator.NewOrchestratorFromClientsAndConfig(
kubeClient,
config,
metrics.NewDAGMetricsClient(kubeClient, true),
)
} else {
defer utils.CleanUpEnvironment(client.CreateKubeClient())
orch = orchestrator.NewOrchestrator(*configPath)
}
orch.Start(1 * time.Second)
go termination.Handle(func() {
orch.Stop()
})
go rest.Serve(*host, *port, orch)
orch.Wait()
}