Skip to content

Commit

Permalink
volume-modifier sidecar elects the same leader as external-resizer si…
Browse files Browse the repository at this point in the history
…decar

Signed-off-by: Hanyue Liang <[email protected]>
  • Loading branch information
hanyuel committed Aug 8, 2023
1 parent c7a70c2 commit fc99f3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ func main() {
if !*enableLeaderElection {
run(context.TODO())
} else {
lockName := "volume-modifier-for-k8s-" + util.SanitizeName(modifierName)
// Ensure volume-modifier-for-k8s and external-resizer sidecars always elect the same leader
// by putting them on the same lease that is identified by the lock name.
externalResizerLockName := "external-resizer-" + util.SanitizeName(driverName)
leKubeClient, err := kubernetes.NewForConfig(config)
if err != nil {
klog.Fatal(err.Error())
}
le := leaderelection.NewLeaderElection(leKubeClient, lockName, run)
le := leaderelection.NewLeaderElection(leKubeClient, externalResizerLockName, run)
if *httpEndpoint != "" {
le.PrepareHealthCheck(mux, leaderelection.DefaultHealthCheckTimeout)
}
Expand Down

0 comments on commit fc99f3c

Please sign in to comment.