Skip to content

Commit

Permalink
rbd: use leases for leader election
Browse files Browse the repository at this point in the history
use leases for leader election instead
of the deprecated configmap based leader
election.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Apr 11, 2022
1 parent 959df4d commit e30e785
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/ceph/ceph-csi/internal/util/log"

"k8s.io/client-go/tools/leaderelection/resourcelock"
clientConfig "sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
Expand Down Expand Up @@ -59,9 +60,10 @@ func Start(config Config) error {
opts := manager.Options{
LeaderElection: true,
// disable metrics
MetricsBindAddress: "0",
LeaderElectionNamespace: config.Namespace,
LeaderElectionID: electionID,
MetricsBindAddress: "0",
LeaderElectionNamespace: config.Namespace,
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
LeaderElectionID: electionID,
}
mgr, err := manager.New(clientConfig.GetConfigOrDie(), opts)
if err != nil {
Expand Down

0 comments on commit e30e785

Please sign in to comment.