Skip to content
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

feat: Allow configuring leader election namespace #1333

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 12 additions & 7 deletions cmd/gpu-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func init() {
func main() {
var metricsAddr string
var enableLeaderElection bool
var leaderElectionNamespace string
var probeAddr string
var renewDeadline time.Duration

Expand All @@ -82,6 +83,9 @@ func main() {
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&leaderElectionNamespace, "leader-elect-namespace", "",
"Set the leader lease namespace for the controller manager. "+
"If undefined, the leader election namespace defaults to the namespace the operator is running in.")
flag.DurationVar(&renewDeadline, "leader-lease-renew-deadline", 0,
"Set the leader lease renew deadline duration (e.g. \"10s\") of the controller manager. "+
"Only enabled when the --leader-elect flag is set. "+
Expand Down Expand Up @@ -117,13 +121,14 @@ func main() {
}

options := ctrl.Options{
Scheme: scheme,
Metrics: metricsOptions,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "53822513.nvidia.com",
WebhookServer: webhookServer,
Cache: cacheOptions,
Scheme: scheme,
Metrics: metricsOptions,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "53822513.nvidia.com",
WebhookServer: webhookServer,
Cache: cacheOptions,
}

if enableLeaderElection && int(renewDeadline) != 0 {
Expand Down