diff --git a/cmd/main.go b/cmd/main.go index b8d0170d4..b87a725f2 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -25,7 +25,6 @@ import ( "runtime" configv1 "github.com/openshift/api/config/v1" - "github.com/operator-framework/operator-lib/leader" "github.com/submariner-io/admiral/pkg/log/kzerolog" "github.com/submariner-io/admiral/pkg/names" admversion "github.com/submariner-io/admiral/pkg/version" @@ -84,8 +83,7 @@ func main() { flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.StringVar(&pprofAddr, "pprof-bind-address", ":8082", "The address the profiling 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.") + "Enable leader election for the controller manager to ensure there is only one active instance.") kzerolog.AddFlags(nil) flag.Parse() @@ -121,13 +119,6 @@ func main() { ctx := ctrl.SetupSignalHandler() - // Become the leader before proceeding - err = leader.Become(ctx, "submariner-operator-lock") - if err != nil { - log.Error(err, "") - os.Exit(1) - } - // Set up the CRDs we need crdUpdater, err := crd.UpdaterFromRestConfig(cfg) if err != nil { diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index b336645d5..92d570c99 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -54,8 +54,8 @@ spec: image: controller:0.0.0 command: - submariner-operator - # args: - # - --enable-leader-election + args: + - --leader-elect imagePullPolicy: Always env: - name: WATCH_NAMESPACE diff --git a/config/rbac/submariner-operator/role.yaml b/config/rbac/submariner-operator/role.yaml index 91d88aed2..cca136ddf 100644 --- a/config/rbac/submariner-operator/role.yaml +++ b/config/rbac/submariner-operator/role.yaml @@ -93,3 +93,14 @@ rules: - servicediscoveries/finalizers verbs: - update + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - delete