-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (50 loc) · 1.48 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
package main
import (
"context"
"flag"
"k8s.io/klog/v2"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"github.com/mjwolf/operator/pkg/subscription"
"github.com/mjwolf/operator/pkg/runtime"
)
var (
addr = flag.String("listen-addr", ":8080", "the listen address")
kubeconfig string
masterURL string
)
func main() {
flag.Parse()
klog.Info("Starting operator...")
kubeCfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
if err != nil {
klog.Fatalf("Error building kubeconfig: %s", err.Error())
}
defaultKubernetesClientSet, err := kubernetes.NewForConfig(kubeCfg)
if err != nil {
klog.Fatalf("watcher clientset: %s", err.Error())
}
// Context
context := context.TODO()
configMapSubscription := &subscription.ConfigMapSubscription{
ClientSet: defaultKubernetesClientSet,
Ctx: context,
}
podSubscription := &subscription.PodSubscription{
ClientSet: defaultKubernetesClientSet,
Ctx: context,
ConfigMapSubscriptRef: configMapSubscription,
}
configMapSubscription.PodSubscriptRef = podSubscription
if err := runtime.RunLoop([]subscription.ISubscription{
podSubscription,
configMapSubscription,
}); err != nil {
klog.Fatalf(err.Error())
}
klog.Info("End of main!")
}
func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to kubeconfig")
flag.StringVar(&masterURL, "master", "", "The address of the k8s server")
}