-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 892 Bytes
/
main.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
package main
import (
"log"
"os"
"os/signal"
"syscall"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
var (
clientset *kubernetes.Clientset
)
func main() {
// setup kubernetes client
clsConfig, err := rest.InClusterConfig()
if err != nil {
log.Fatal(err)
}
clientset, err = kubernetes.NewForConfig(clsConfig)
if err != nil {
log.Fatal(err)
}
loadConfig()
// check run mode and start controller or target
log.Printf("Starting gke-service-sync in '%s' mode.", defaultConfig.RunMode)
switch defaultConfig.RunMode {
case runModeController:
go syncServicesController()
case runModeTarget:
go syncServicesTarget()
default:
go syncServicesController()
go syncServicesTarget()
}
// handle shutdown
shutdown := make(chan os.Signal)
signal.Notify(shutdown, syscall.SIGTERM, syscall.SIGINT)
// wait for shutdown
<-shutdown
log.Printf("Exit")
}