Skip to content

Commit

Permalink
feat: migrate leaderelection lock to leases
Browse files Browse the repository at this point in the history
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
  • Loading branch information
tao12345666333 committed Jun 23, 2022
1 parent 7806159 commit c9a6a0d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions internal/ingress/controller/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,24 @@ func setupLeaderElection(config *leaderElectionConfig) {
Host: hostname,
})

lock := resourcelock.ConfigMapLock{
ConfigMapMeta: metav1.ObjectMeta{Namespace: k8s.IngressPodDetails.Namespace, Name: config.ElectionID},
Client: config.Client.CoreV1(),
LockConfig: resourcelock.ResourceLockConfig{
Identity: k8s.IngressPodDetails.Name,
EventRecorder: recorder,
objectMeta := metav1.ObjectMeta{Namespace: k8s.IngressPodDetails.Namespace, Name: config.ElectionID}
resourceLockConfig := resourcelock.ResourceLockConfig{
Identity: k8s.IngressPodDetails.Name,
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,
},
}

Expand Down

0 comments on commit c9a6a0d

Please sign in to comment.