forked from roboll/kube-vault-controller
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
58 lines (46 loc) · 1.35 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
package main
import (
"flag"
"log"
"k8s.io/client-go/tools/clientcmd"
vault "github.com/hashicorp/vault/api"
"github.com/roboll/kube-vault-controller/pkg/controller"
_ "github.com/roboll/kube-vault-controller/pkg/kube/install"
)
var (
vaddr = flag.String("vault", "", "(optional) Vault address.")
apiserver = flag.String("apiserver", "", "(optional) Kubernetes apiserver url.")
kubeconfig = flag.String("kubeconfig", "", "Path to the kubeconfig file. Defaults to in-cluster config.")
namespace = flag.String("namespace", "", "Namespace to watch for claims.")
syncPeriod = flag.Duration("sync-period", 0, "Sync all resources each period.")
)
func main() {
flag.Parse()
log.Printf("kube-vault-controller starting, sync period %s.", *syncPeriod)
if *namespace != "" {
log.Printf("watching namespace %s.", *namespace)
}
vconfig := vault.DefaultConfig()
err := vconfig.ReadEnvironment()
if err != nil {
panic(err.Error())
}
if *vaddr != "" {
vconfig.Address = *vaddr
}
kconfig, err := clientcmd.BuildConfigFromFlags(*apiserver, *kubeconfig)
if err != nil {
panic(err.Error())
}
config := &controller.Config{
Namespace: *namespace,
SyncPeriod: *syncPeriod,
}
ctrl, err := controller.New(config, vconfig, kconfig)
if err != nil {
panic(err.Error())
}
stop := make(chan struct{})
go ctrl.Run(stop)
<-make(chan struct{})
}