Skip to content

Commit 79b7642

Browse files
committed
feat(chart): add leaderElection.leaseDuration and leaderElection.renewDeadline
fix: #606
1 parent c2ae1d1 commit 79b7642

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

charts/mysql-operator/templates/deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ spec:
7070
- --health-probe-bind-address=:8081
7171
- --metrics-bind-address=127.0.0.1:8080
7272
- --leader-elect
73+
- {{ printf "--lease-duration=%s" .Values.leaderElection.leaseDuration }}
74+
- {{ printf "--renew-deadline=%s" .Values.leaderElection.renewDeadline }}
7375
{{- if not .Values.imagePrefix }}
7476
image: "{{ .Values.manager.image }}:{{ .Values.manager.tag }}"
7577
{{- else }}

charts/mysql-operator/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ rbacProxy:
5151

5252
leaderElection:
5353
create: true
54+
leaseDuration: 15s
55+
renewDeadline: 10s
5456

5557
serviceMonitor:
5658
enabled: true

cmd/manager/main.go

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"flag"
2121
"os"
2222
"sync"
23+
"time"
2324

2425
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2526
// to ensure that exec-entrypoint and run can make use of them.
@@ -55,11 +56,15 @@ func main() {
5556
var metricsAddr string
5657
var enableLeaderElection bool
5758
var probeAddr string
59+
var leaseDuration time.Duration
60+
var renewDeadline time.Duration
5861
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
5962
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
6063
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
6164
"Enable leader election for controller manager. "+
6265
"Enabling this will ensure there is only one active controller manager.")
66+
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.")
67+
flag.DurationVar(&renewDeadline, "renew-deadline", time.Second*10, "The duration that the acting controlplane will retry refreshing leadership before giving up.")
6368
opts := zap.Options{
6469
Development: true,
6570
}
@@ -75,6 +80,8 @@ func main() {
7580
HealthProbeBindAddress: probeAddr,
7681
LeaderElection: enableLeaderElection,
7782
LeaderElectionID: "2175edb9.radondb.com",
83+
LeaseDuration: &leaseDuration,
84+
RenewDeadline: &renewDeadline,
7885
})
7986
if err != nil {
8087
setupLog.Error(err, "unable to start manager")

0 commit comments

Comments
 (0)