aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/nfn-operator
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2019-08-06 19:35:42 -0700
committerRitu Sood <ritu.sood@intel.com>2019-08-15 10:03:47 -0700
commit8295a28f6d6e14f5adb62138271de393015061e9 (patch)
treed11b1e799de55e89d08bc810180d99ce65e6f21e /cmd/nfn-operator
parentaa41b49246d84b605a76d169f0c861ba0691a4fb (diff)
Use controller runtime and operator sdk
Changing the framework to use controller runtime and operator sdk. This allows to add CRD controllers for Network, Provider Network etc in the same operator. Binary renamed to nfn-operator (Network funtion networking). Change-Id: Ic25a3c3f5f1418fc0614f3aede48b41d9c1156cd Signed-off-by: Ritu Sood <ritu.sood@intel.com>
Diffstat (limited to 'cmd/nfn-operator')
-rw-r--r--cmd/nfn-operator/nfn-operator.go91
1 files changed, 91 insertions, 0 deletions
diff --git a/cmd/nfn-operator/nfn-operator.go b/cmd/nfn-operator/nfn-operator.go
new file mode 100644
index 0000000..2925ac6
--- /dev/null
+++ b/cmd/nfn-operator/nfn-operator.go
@@ -0,0 +1,91 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "runtime"
+
+ // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
+ _ "k8s.io/client-go/plugin/pkg/client/auth"
+
+ "github.com/spf13/pflag"
+// "ovn4nfv-k8s-plugin/pkg/apis"
+ "ovn4nfv-k8s-plugin/internal/pkg/ovn"
+ "ovn4nfv-k8s-plugin/pkg/controller"
+ "sigs.k8s.io/controller-runtime/pkg/client/config"
+ "sigs.k8s.io/controller-runtime/pkg/log/zap"
+ "sigs.k8s.io/controller-runtime/pkg/manager"
+ logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
+ "sigs.k8s.io/controller-runtime/pkg/runtime/signals"
+)
+
+var log = logf.Log.WithName("nfn-operator")
+
+func printVersion() {
+ log.Info(fmt.Sprintf("Go Version: %s", runtime.Version()))
+ log.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
+}
+
+func main() {
+
+ // Add flags registered by imported packages (e.g. glog and
+ // controller-runtime)
+ pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
+
+ pflag.Parse()
+
+ // Use a zap logr.Logger implementation. If none of the zap
+ // flags are configured (or if the zap flag set is not being
+ // used), this defaults to a production zap logger.
+ //
+ // The logger instantiated here can be changed to any logger
+ // implementing the logr.Logger interface. This logger will
+ // be propagated through the whole operator, generating
+ // uniform and structured logs.
+ logf.SetLogger(zap.Logger(true))
+
+ printVersion()
+
+ // Create an OVN Controller
+ _, err := ovn.NewOvnController(nil)
+ if err != nil {
+ log.Error(err, "")
+ os.Exit(1)
+ }
+ //Initialize all the controllers that are supported here
+
+ // Get a config to talk to the apiserver
+ cfg, err := config.GetConfig()
+ if err != nil {
+ log.Error(err, "")
+ os.Exit(1)
+ }
+ // Create a new Cmd to provide shared dependencies and start components
+ mgr, err := manager.New(cfg, manager.Options{})
+ if err != nil {
+ log.Error(err, "")
+ os.Exit(1)
+ }
+
+ log.Info("Registering Components.")
+
+ // Setup Scheme for all resources
+ //if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
+ // log.Error(err, "")
+ // os.Exit(1)
+ //}
+
+ // Setup all Controllers
+ if err := controller.AddToManager(mgr); err != nil {
+ log.Error(err, "")
+ os.Exit(1)
+ }
+ log.Info("Starting the Cmd.")
+
+ // Start the Cmd
+ if err := mgr.Start(signals.SetupSignalHandler()); err != nil {
+ log.Error(err, "Manager exited non-zero")
+ os.Exit(1)
+ }
+}