feat: using LeaseLock for election (#8921)
We removed the use of configmap as an election lock, so we will use the Lease API to complete the election. Before this, we used `MultiLock` to facilitate smooth migration of existing users of ingress-nginx from configmap to LeaseLock. Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com> Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
This commit is contained in:
parent
fe09f6d096
commit
730174f73d
3 changed files with 8 additions and 32 deletions
|
|
@ -99,25 +99,16 @@ func setupLeaderElection(config *leaderElectionConfig) {
|
|||
EventRecorder: recorder,
|
||||
}
|
||||
|
||||
// TODO: If we upgrade client-go to v0.24 then we can only use LeaseLock.
|
||||
// MultiLock is used for lock's migration
|
||||
lock := resourcelock.MultiLock{
|
||||
Primary: &resourcelock.ConfigMapLock{
|
||||
ConfigMapMeta: objectMeta,
|
||||
Client: config.Client.CoreV1(),
|
||||
LockConfig: resourceLockConfig,
|
||||
},
|
||||
Secondary: &resourcelock.LeaseLock{
|
||||
LeaseMeta: objectMeta,
|
||||
Client: config.Client.CoordinationV1(),
|
||||
LockConfig: resourceLockConfig,
|
||||
},
|
||||
lock := &resourcelock.LeaseLock{
|
||||
LeaseMeta: objectMeta,
|
||||
Client: config.Client.CoordinationV1(),
|
||||
LockConfig: resourceLockConfig,
|
||||
}
|
||||
|
||||
ttl := 30 * time.Second
|
||||
|
||||
elector, err := leaderelection.NewLeaderElector(leaderelection.LeaderElectionConfig{
|
||||
Lock: &lock,
|
||||
Lock: lock,
|
||||
LeaseDuration: ttl,
|
||||
RenewDeadline: ttl / 2,
|
||||
RetryPeriod: ttl / 4,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue