-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
72 lines (59 loc) · 2.15 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"
"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/prob-notebook-controller/pkg/controller"
"github.com/statcan/prob-notebook-controller/pkg/signals"
istio "istio.io/client-go/pkg/clientset/versioned"
istioinformers "istio.io/client-go/pkg/informers/externalversions"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"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)
}
istioclient, err := istio.NewForConfig(cfg)
if err != nil {
log.Fatalf("error building istio client: %v", err)
}
kubeflowclient, err := kubeflow.NewForConfig(cfg)
if err != nil {
log.Fatalf("error building kubeflow client: %v", err)
}
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeclient, time.Second*30)
istioInformerFactory := istioinformers.NewSharedInformerFactory(istioclient, time.Second*30)
kubeflowInformerFactory := informers.NewSharedInformerFactory(kubeflowclient, time.Second*30)
ctlr := controller.NewController(
kubeclient,
istioclient,
kubeflowclient,
kubeflowInformerFactory.Kubeflow().V1().Notebooks(),
istioInformerFactory.Security().V1beta1().AuthorizationPolicies(),
)
kubeInformerFactory.Start(stopCh)
istioInformerFactory.Start(stopCh)
kubeflowInformerFactory.Start(stopCh)
if err = ctlr.Run(2, stopCh); err != nil {
log.Fatalf("error running controller: %v", err)
}
}