Skip to content

Commit

Permalink
Switch leader election resource lock to leases only
Browse files Browse the repository at this point in the history
This feature has been on by default since v1.14 and this operator was
never deployed anywhere.
  • Loading branch information
annismckenzie committed Jan 6, 2021
1 parent 1e8cf96 commit 2e990b4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/leaderelection/resourcelock"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

Expand Down Expand Up @@ -70,13 +71,13 @@ func main() {
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Namespace: consts.GetNamespace(),
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: "8a68cfa7.operators.annismckenzie.github.com",

Scheme: scheme,
Namespace: consts.GetNamespace(),
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: "8a68cfa7.operators.annismckenzie.github.com",
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
LeaderElectionReleaseOnCancel: true, // make the leader step down voluntarily when the manager ends
})
if err != nil {
Expand Down

0 comments on commit 2e990b4

Please sign in to comment.