Skip to content

Commit

Permalink
configurable watch namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhachyan authored and yorugac committed May 23, 2023
1 parent 9d94096 commit 306d189
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseDevMode(true)))

watchNamespace := getWatchNamespace()

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: "fcdfce80.io",
LeaderElectionResourceLock: "configmapsleases",
Namespace: watchNamespace,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand All @@ -85,3 +88,13 @@ func main() {
os.Exit(1)
}
}

func getWatchNamespace() string {
var watchNamespaceEnvVar = "WATCH_NAMESPACE"

ns, found := os.LookupEnv(watchNamespaceEnvVar)
if !found {
return ""
}
return ns
}

0 comments on commit 306d189

Please sign in to comment.