9 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
10 _ "k8s.io/client-go/plugin/pkg/client/auth"
12 "github.com/spf13/pflag"
13 notif "ovn4nfv-k8s-plugin/internal/pkg/nfnNotify"
14 "ovn4nfv-k8s-plugin/internal/pkg/ovn"
15 "ovn4nfv-k8s-plugin/pkg/apis"
16 "ovn4nfv-k8s-plugin/pkg/controller"
17 "sigs.k8s.io/controller-runtime/pkg/client/config"
18 "sigs.k8s.io/controller-runtime/pkg/log/zap"
19 "sigs.k8s.io/controller-runtime/pkg/manager"
20 logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
21 "sigs.k8s.io/controller-runtime/pkg/runtime/signals"
24 var log = logf.Log.WithName("nfn-operator")
27 log.Info(fmt.Sprintf("Go Version: %s", runtime.Version()))
28 log.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
33 // Add flags registered by imported packages (e.g. glog and
34 // controller-runtime)
35 pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
39 // Use a zap logr.Logger implementation. If none of the zap
40 // flags are configured (or if the zap flag set is not being
41 // used), this defaults to a production zap logger.
43 // The logger instantiated here can be changed to any logger
44 // implementing the logr.Logger interface. This logger will
45 // be propagated through the whole operator, generating
46 // uniform and structured logs.
47 logf.SetLogger(zap.Logger(true))
51 // Create an OVN Controller
52 _, err := ovn.NewOvnController(nil)
57 //Initialize all the controllers that are supported here
59 // Get a config to talk to the apiserver
60 cfg, err := config.GetConfig()
66 // Start GRPC Notification Server
67 go notif.SetupNotifServer(cfg)
69 // Create a new Cmd to provide shared dependencies and start components
70 mgr, err := manager.New(cfg, manager.Options{})
76 log.Info("Registering Components.")
78 // Setup Scheme for all resources
79 if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
84 // Setup all Controllers
85 if err := controller.AddToManager(mgr); err != nil {
89 log.Info("Starting the Cmd.")
92 if err := mgr.Start(signals.SetupSignalHandler()); err != nil {
93 log.Error(err, "Manager exited non-zero")