Skip to content

Commit

Permalink
Support configure election timeouts (#382)
Browse files Browse the repository at this point in the history
Signed-off-by: Chunyi Lyu <[email protected]>
  • Loading branch information
ChunyiLyu authored Jan 30, 2024
1 parent c5441fa commit 00476d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ func main() {
var enableLeaderElection bool
var probeAddr string
var migrateFromVMware bool
var leaseDuration time.Duration
var renewDeadline time.Duration
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&migrateFromVMware, "migrate-from-vmware", false,
"Enable migration from the VMware implementation.")
// Default values taken from: https://github.com/kubernetes-sigs/controller-runtime/blob/b88ed7a3602b85b6cfd0acfe9c25033b978bdb83/pkg/manager/internal.go#L52-L53
flag.DurationVar(&leaseDuration, "leader-elect-lease-duration", 15*time.Second, "configure leader election lease duration")
flag.DurationVar(&renewDeadline, "leader-elect-renew-deadline", 10*time.Second, "configure leader election renew deadline")
opts := zap.Options{
Development: true,
}
Expand All @@ -102,6 +107,8 @@ func main() {
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "a359ffaf.servicebinding.io",
LeaseDuration: &leaseDuration,
RenewDeadline: &renewDeadline,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down

0 comments on commit 00476d7

Please sign in to comment.