@@ -142,11 +142,26 @@ type Options struct {
142142 // starting the manager.
143143 LeaderElection bool
144144
145+ // LeaderElectionResourceLock determines which resource lock to use for leader election,
146+ // defaults to "configmapsleases". Change this value only if you know what you are doing.
147+ // Otherwise, users of your controller might end up with multiple running instances that
148+ // each acquired leadership through different resource locks during upgrades and thus
149+ // act on the same resources concurrently.
150+ // If you want to migrate to the "leases" resource lock, you might do so by migrating to the
151+ // respective multilock first ("configmapsleases" or "endpointsleases"), which will acquire a
152+ // leader lock on both resources. After all your users have migrated to the multilock, you can
153+ // go ahead and migrate to "leases". Please also keep in mind, that users might skip versions
154+ // of your controller.
155+ //
156+ // Note: before controller-runtime version v0.7, the resource lock was set to "configmaps".
157+ // Please keep this in mind, when planning a proper migration path for your controller.
158+ LeaderElectionResourceLock string
159+
145160 // LeaderElectionNamespace determines the namespace in which the leader
146- // election configmap will be created.
161+ // election resource will be created.
147162 LeaderElectionNamespace string
148163
149- // LeaderElectionID determines the name of the configmap that leader election
164+ // LeaderElectionID determines the name of the resource that leader election
150165 // will use for holding the leader lock.
151166 LeaderElectionID string
152167
@@ -329,9 +344,10 @@ func New(config *rest.Config, options Options) (Manager, error) {
329344 leaderConfig = options .LeaderElectionConfig
330345 }
331346 resourceLock , err := options .newResourceLock (leaderConfig , recorderProvider , leaderelection.Options {
332- LeaderElection : options .LeaderElection ,
333- LeaderElectionID : options .LeaderElectionID ,
334- LeaderElectionNamespace : options .LeaderElectionNamespace ,
347+ LeaderElection : options .LeaderElection ,
348+ LeaderElectionResourceLock : options .LeaderElectionResourceLock ,
349+ LeaderElectionID : options .LeaderElectionID ,
350+ LeaderElectionNamespace : options .LeaderElectionNamespace ,
335351 })
336352 if err != nil {
337353 return nil , err
0 commit comments