Skip to content

chart: add leaderElection.leaseDuration and leaderElection.renewDeadline #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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