-
Notifications
You must be signed in to change notification settings - Fork 27
/
tgik-controller.go
47 lines (40 loc) · 1.04 KB
/
tgik-controller.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
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
"github.com/jbeda/tgik-controller/version"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
func main() {
log.Printf("tgik-controller version %s", version.VERSION)
kubeconfig := ""
flag.StringVar(&kubeconfig, "kubeconfig", kubeconfig, "kubeconfig file")
flag.Parse()
if kubeconfig == "" {
kubeconfig = os.Getenv("KUBECONFIG")
}
var (
config *rest.Config
err error
)
if kubeconfig != "" {
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
} else {
config, err = rest.InClusterConfig()
}
if err != nil {
fmt.Fprintf(os.Stderr, "error creating client: %v", err)
os.Exit(1)
}
client := kubernetes.NewForConfigOrDie(config)
sharedInformers := informers.NewSharedInformerFactory(client, 10*time.Minute)
tgikController := NewTGIKController(client, sharedInformers.Core().V1().Secrets(), sharedInformers.Core().V1().Namespaces())
sharedInformers.Start(nil)
tgikController.Run(nil)
}