Skip to content

Commit

Permalink
disable leader election when controller is not enabled (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
kishorj authored Jul 10, 2023
1 parent 2a23099 commit 0779bcf
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@ func main() {
setupLog.Error(err, "unable to build REST config")
os.Exit(1)
}
rtOpts := config.BuildRuntimeOptions(controllerCFG.RuntimeConfig, scheme)

mgr, err := ctrl.NewManager(restCFG, rtOpts)
if err != nil {
setupLog.Error(err, "unable to create controller manager")
os.Exit(1)
}
clientSet, err := kubernetes.NewForConfig(mgr.GetConfig())
clientSet, err := kubernetes.NewForConfig(restCFG)
if err != nil {
setupLog.Error(err, "unable to obtain clientSet")
os.Exit(1)
Expand All @@ -104,6 +97,18 @@ func main() {
os.Exit(1)
}
enableNetworkPolicyController = configMapManager.IsControllerEnabled()
if !enableNetworkPolicyController {
setupLog.Info("Disabling leader election since network policy controller is not enabled")
controllerCFG.RuntimeConfig.EnableLeaderElection = false
}
}

rtOpts := config.BuildRuntimeOptions(controllerCFG.RuntimeConfig, scheme)

mgr, err := ctrl.NewManager(restCFG, rtOpts)
if err != nil {
setupLog.Error(err, "unable to create controller manager")
os.Exit(1)
}

policyEndpointsManager := policyendpoints.NewPolicyEndpointsManager(mgr.GetClient(),
Expand Down

0 comments on commit 0779bcf

Please sign in to comment.