Skip to content

Commit

Permalink
feat(RELEASE-1307): increases lease timeout
Browse files Browse the repository at this point in the history
this PR proposes a change in the default leader election
time controls to decrease the etcd load and allowing the
to wait time to renew the leadership, and also decreasing
the number of requests to etcd.

Signed-off-by: Leandro Mendes <[email protected]>
  • Loading branch information
theflockers committed Nov 26, 2024
1 parent eb5da61 commit 3b44dcf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ spec:
- /manager
args:
- --leader-elect
- --lease-duration
- 60
- --leader-renew-deadline
- 30
- --leader-elector-retry-period
- 10
image: controller:latest
name: manager
securityContext:
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"crypto/tls"
"flag"
"os"
"time"

"sigs.k8s.io/controller-runtime/pkg/metrics/server"
crwebhook "sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -70,13 +71,23 @@ func main() {
var metricsAddr string
var enableHttp2 bool
var enableLeaderElection bool
var leaderRenewDeadline time.Duration
var leaseDuration time.Duration
var leaderElectorRetryPeriod time.Duration
var probeAddr string
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(&enableHttp2, "enable-http2", false, "Enable HTTP/2 for the metrics and webhook servers.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.DurationVar(&leaderRenewDeadline, "leader-renew-deadline", 10,
"Leader RenewDeadline is the duration that the acting controlplane "+
"will retry refreshing leadership before giving up.")
flag.DurationVar(&leaseDuration, "lease-duration", 15,
"Lease Duration is the duration that non-leader candidates will wait to force acquire leadership.")
flag.DurationVar(&leaderElectorRetryPeriod, "leader-elector-retry-period", 2, "RetryPeriod is the duration the "+
"LeaderElector clients should wait between tries of actions.")
opts := zap.Options{
Development: true,
TimeEncoder: zapcore.ISO8601TimeEncoder,
Expand All @@ -90,6 +101,9 @@ func main() {
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "f3d4c01a.redhat.com",
RenewDeadline: &leaderRenewDeadline,
LeaseDuration: &leaseDuration,
RetryPeriod: &leaderElectorRetryPeriod,
Metrics: server.Options{
BindAddress: metricsAddr,
},
Expand Down

0 comments on commit 3b44dcf

Please sign in to comment.