mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-27 08:40:23 +00:00
rbd: use leases for leader election
use leases for leader election instead
of the deprecated configmap based leader
election.
This PR is making leases as default leader election
refer https://github.com/kubernetes-sigs/
controller-runtime/pull/1773, default from configmap
to configmap leases was done with
https://github.com/kubernetes-sigs/
controller-runtime/pull/1144.
Release notes https://github.com/kubernetes-sigs/
controller-runtime/releases/tag/v0.7.0
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit d886ab0d66
)
This commit is contained in:
parent
ebf2677b30
commit
e61012da14
@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ceph/ceph-csi/internal/util/log"
|
"github.com/ceph/ceph-csi/internal/util/log"
|
||||||
|
|
||||||
|
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
||||||
clientConfig "sigs.k8s.io/controller-runtime/pkg/client/config"
|
clientConfig "sigs.k8s.io/controller-runtime/pkg/client/config"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
|
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
|
||||||
@ -59,9 +60,10 @@ func Start(config Config) error {
|
|||||||
opts := manager.Options{
|
opts := manager.Options{
|
||||||
LeaderElection: true,
|
LeaderElection: true,
|
||||||
// disable metrics
|
// disable metrics
|
||||||
MetricsBindAddress: "0",
|
MetricsBindAddress: "0",
|
||||||
LeaderElectionNamespace: config.Namespace,
|
LeaderElectionNamespace: config.Namespace,
|
||||||
LeaderElectionID: electionID,
|
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
|
||||||
|
LeaderElectionID: electionID,
|
||||||
}
|
}
|
||||||
mgr, err := manager.New(clientConfig.GetConfigOrDie(), opts)
|
mgr, err := manager.New(clientConfig.GetConfigOrDie(), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user