Skip to content

Commit

Permalink
Merge pull request #10 from hanyuel/leader-elec
Browse files Browse the repository at this point in the history
volume-modifier sidecar elects the same leader as external-resizer sidecar
  • Loading branch information
ConnorJC3 authored Aug 8, 2023
2 parents c7a70c2 + fc99f3c commit 69e91a9
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 69e91a9

Please sign in to comment.