-
Notifications
You must be signed in to change notification settings - Fork 78
/
main.go
72 lines (55 loc) · 1.94 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"flag"
"time"
"context"
"sync"
"github.com/golang/glog"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
clientset "github.com/cloud-ark/kubeplus/platform-operator/pkg/generated/clientset/versioned"
informers "github.com/cloud-ark/kubeplus/platform-operator/pkg/generated/informers/externalversions"
"github.com/cloud-ark/kubeplus/platform-operator/pkg/signals"
"k8s.io/client-go/rest"
)
func main() {
flag.Parse()
// set up signals so we handle the first shutdown signal gracefully
stopCh := signals.SetupSignalHandler()
ctx, cancel := context.WithCancel(context.Background())
// creates the in-cluster config
cfg, err := rest.InClusterConfig()
if err != nil {
panic(err.Error())
}
kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
glog.Fatalf("Error building kubernetes clientset: %s", err.Error())
}
platformOperatorClient, err := clientset.NewForConfig(cfg)
if err != nil {
glog.Fatalf("Error building example clientset: %s", err.Error())
}
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30)
platformInformerFactory := informers.NewSharedInformerFactory(platformOperatorClient, time.Second*30)
platformController := NewPlatformController(kubeClient, platformOperatorClient, kubeInformerFactory, platformInformerFactory)
//resourcePolicyController := NewResourcePolicyController(kubeClient, platformOperatorClient, kubeInformerFactory, platformInformerFactory)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
platformController.Run(1, ctx.Done())
}()
/*
go func() {
defer wg.Done()
resourcePolicyController.Run(1, ctx.Done())
}()
*/
go kubeInformerFactory.Start(ctx.Done())
go platformInformerFactory.Start(ctx.Done())
<-stopCh
cancel()
}