From e7d4969790c3d86ceac034a5026ffdb60a9c06a1 Mon Sep 17 00:00:00 2001 From: vikaschoudhary16 Date: Wed, 24 Apr 2019 15:37:56 +0530 Subject: [PATCH] Add support for passing namespace cmdline flag to the manager --- cmd/manager/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index e46e7cbde132..f10eb99060b0 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -33,8 +33,14 @@ import ( func main() { flag.Set("logtostderr", "true") klog.InitFlags(nil) - flag.Parse() + watchNamespace := flag.String("namespace", "", + "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") + flag.Parse() + if *watchNamespace != "" { + log.Printf("Watching cluster-api objects only in namespace %q for reconciliation.", *watchNamespace) + } + log.Printf("Registering Components.") // Get a config to talk to the apiserver cfg, err := config.GetConfig() if err != nil { @@ -45,6 +51,7 @@ func main() { syncPeriod := 10 * time.Minute mgr, err := manager.New(cfg, manager.Options{ SyncPeriod: &syncPeriod, + Namespace: *watchNamespace, }) if err != nil { log.Fatal(err)