Skip to content

Commit 387a726

Browse files
committed
Add namespace flag
1 parent e3a7e32 commit 387a726

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cmd/manager/main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
func main() {
3737
var printVersion bool
3838
flag.BoolVar(&printVersion, "version", false, "print version and exit")
39+
watchNamespace := flag.String("namespace", "", "Namespace that the controller watches to reconcile machine-api objects. If unspecified, the controller watches for machine-api objects across all namespaces.")
3940

4041
klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
4142
klog.InitFlags(klogFlags)
@@ -60,11 +61,17 @@ func main() {
6061
glog.Fatalf("Error getting configuration: %v", err)
6162
}
6263

63-
// Create a new Cmd to provide shared dependencies and start components
64+
// Setup a Manager
6465
syncPeriod := 10 * time.Minute
65-
mgr, err := manager.New(cfg, manager.Options{
66+
opts := manager.Options{
6667
SyncPeriod: &syncPeriod,
67-
})
68+
}
69+
if *watchNamespace != "" {
70+
opts.Namespace = *watchNamespace
71+
klog.Infof("Watching machine-api objects only in namespace %q for reconciliation.", opts.Namespace)
72+
}
73+
74+
mgr, err := manager.New(cfg, opts)
6875
if err != nil {
6976
glog.Fatalf("Error creating manager: %v", err)
7077
}

0 commit comments

Comments
 (0)