-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
66 lines (54 loc) · 1.93 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
package main
import (
"flag"
"log"
"time"
kubeflow "github.com/StatCan/kubeflow-controller/pkg/generated/clientset/versioned"
informers "github.com/StatCan/kubeflow-controller/pkg/generated/informers/externalversions"
"github.com/statcan/profile-state-controller/pkg/controller"
"github.com/statcan/profile-state-controller/pkg/signals"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/clientcmd"
)
var (
masterURL string
kubeconfig string
)
func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.Parse()
}
func main() {
stopCh := signals.SetupSignalHandler()
cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
if err != nil {
log.Fatalf("error building kubeconfig: %v", err)
}
kubeclient, err := kubernetes.NewForConfig(cfg)
if err != nil {
log.Fatalf("error building kubernetes clientset: %v", err)
}
kubeflowclient, err := kubeflow.NewForConfig(cfg)
if err != nil {
log.Fatalf("error building kubeflow client: %v", err)
}
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeclient, time.Minute*5)
kubeflowInformerFactory := informers.NewSharedInformerFactory(kubeflowclient, time.Minute*5)
ctlr := controller.NewController(
kubeclient,
kubeflowclient,
kubeflowInformerFactory.Kubeflow().V1().Profiles(),
kubeInformerFactory.Core().V1().Namespaces(),
kubeInformerFactory.Core().V1().Pods(),
kubeInformerFactory.Rbac().V1().RoleBindings(),
kubeInformerFactory.Core().V1().PersistentVolumeClaims(),
)
kubeInformerFactory.Start(stopCh)
kubeflowInformerFactory.Start(stopCh)
if err = ctlr.Run(2, stopCh); err != nil {
log.Fatalf("error running controller: %v", err)
}
}