This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
55 lines (45 loc) · 1.6 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
package main
import (
"flag"
"fmt"
"github.com/acorn-io/acorn-istio-plugin/pkg/controller"
"github.com/acorn-io/acorn-istio-plugin/pkg/scheme"
"github.com/acorn-io/acorn-istio-plugin/pkg/version"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
"github.com/acorn-io/baaah/pkg/restconfig"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
)
var (
versionFlag = flag.Bool("version", false, "print version and exit")
debugImageFlag = flag.String("debug-image", "ghcr.io/acorn-io/acorn-istio-plugin:main", "Container image used to kill Istio sidecars (needs to have curl installed)")
allowTrafficFromNamespaces = flag.String("allow-traffic-from-namespaces", "", `Extra namespaces that should be allowed to send traffic to all Acorn apps (comma-separated).
Pods in these namespaces must be part of the Istio service mesh in order to send traffic.`)
)
func main() {
flag.Parse()
logrus.SetLevel(logrus.ErrorLevel)
fmt.Printf("Version: %s\n", version.Get())
if *versionFlag {
return
}
config, err := restconfig.Default()
if err != nil {
logrus.Fatal(err)
}
config.APIPath = "api"
config.GroupVersion = &corev1.SchemeGroupVersion
config.NegotiatedSerializer = scheme.Codecs
k8s := kubernetes.NewForConfigOrDie(config)
ctx := signals.SetupSignalHandler()
if err := controller.Start(ctx, controller.Options{
K8s: k8s,
DebugImage: *debugImageFlag,
AllowTrafficFromNamespaces: *allowTrafficFromNamespaces,
}); err != nil {
logrus.Fatal(err)
}
<-ctx.Done()
logrus.Fatal(ctx.Err())
}