Skip to content

Commit

Permalink
feat(chart): add leaderElection.leaseDuration and leaderElection.rene…
Browse files Browse the repository at this point in the history
…wDeadline

fix: radondb#606
  • Loading branch information
runkecheng committed Jul 19, 2022
1 parent c2ae1d1 commit 79b7642
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions charts/mysql-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ spec:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- {{ printf "--lease-duration=%s" .Values.leaderElection.leaseDuration }}
- {{ printf "--renew-deadline=%s" .Values.leaderElection.renewDeadline }}
{{- if not .Values.imagePrefix }}
image: "{{ .Values.manager.image }}:{{ .Values.manager.tag }}"
{{- else }}
Expand Down
2 changes: 2 additions & 0 deletions charts/mysql-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ rbacProxy:

leaderElection:
create: true
leaseDuration: 15s
renewDeadline: 10s

serviceMonitor:
enabled: true
Expand Down
7 changes: 7 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"flag"
"os"
"sync"
"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand Down Expand Up @@ -55,11 +56,15 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
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.DurationVar(&leaseDuration, "lease-duration", time.Second*15, "The duration that non-leader candidates will wait to force acquire leadership, this is measured against time of last observed ack.")
flag.DurationVar(&renewDeadline, "renew-deadline", time.Second*10, "The duration that the acting controlplane will retry refreshing leadership before giving up.")
opts := zap.Options{
Development: true,
}
Expand All @@ -75,6 +80,8 @@ func main() {
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "2175edb9.radondb.com",
LeaseDuration: &leaseDuration,
RenewDeadline: &renewDeadline,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down

0 comments on commit 79b7642

Please sign in to comment.