@@ -18,6 +18,7 @@ limitations under the License.
1818package main
1919
2020import (
21+ "crypto/sha256"
2122 "crypto/tls"
2223 "flag"
2324 "fmt"
@@ -162,6 +163,7 @@ func main() {
162163 bininfo .Component (), bininfo .VersionOr ("devel" ), gruntime .GOOS , gruntime .GOARCH ,
163164 bininfo .CommitOr ("edge" ))
164165
166+ leaderElectionID := "4c28796a.cloud.sap"
165167 var cacheOptions cache.Options
166168 if global .LabelSelector != "" {
167169 setupLog .Info ("setting up cache with label selector" , "selector" , global .LabelSelector )
@@ -182,6 +184,10 @@ func main() {
182184 },
183185 },
184186 }
187+
188+ h := sha256 .New ()
189+ h .Write ([]byte (global .LabelSelector ))
190+ leaderElectionID = fmt .Sprintf ("%x.cloud.sap" , h .Sum (nil ))
185191 }
186192
187193 mgr , err := ctrl .NewManager (restConfig , ctrl.Options {
@@ -190,7 +196,7 @@ func main() {
190196 WebhookServer : webhookServer ,
191197 HealthProbeBindAddress : probeAddr ,
192198 LeaderElection : enableLeaderElection ,
193- LeaderElectionID : "4c28796a.cloud.sap" ,
199+ LeaderElectionID : leaderElectionID ,
194200 // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
195201 // when the Manager ends. This requires the binary to immediately end when the
196202 // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
0 commit comments