Skip to content

Commit

Permalink
Merge pull request #7233 from Duke0404/master
Browse files Browse the repository at this point in the history
Add lease resource name customization using flag
  • Loading branch information
k8s-ci-robot authored Sep 4, 2024
2 parents 8e11684 + c382519 commit bc49822
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func multiStringFlag(name string, usage string) *MultiStringFlag {
}

var (
leaseResourceName = flag.String("lease-resource-name", "cluster-autoscaler", "The lease resource to use in leader election.")
clusterName = flag.String("cluster-name", "", "Autoscaled cluster name, if available")
address = flag.String("address", ":8085", "The address to expose prometheus metrics.")
kubernetes = flag.String("kubernetes", "", "Kubernetes master location. Leave blank for default")
Expand Down Expand Up @@ -643,10 +644,6 @@ func run(healthCheck *metrics.HealthCheck, debuggingSnapshotter debuggingsnapsho
func main() {
klog.InitFlags(nil)

leaderElection := defaultLeaderElectionConfiguration()
leaderElection.LeaderElect = true
componentopts.BindLeaderElectionFlags(&leaderElection, pflag.CommandLine)

featureGate := utilfeature.DefaultMutableFeatureGate
loggingConfig := logsapi.NewLoggingConfiguration()

Expand All @@ -658,6 +655,10 @@ func main() {
featureGate.AddFlag(pflag.CommandLine)
kube_flag.InitFlags()

leaderElection := defaultLeaderElectionConfiguration()
leaderElection.LeaderElect = true
componentopts.BindLeaderElectionFlags(&leaderElection, pflag.CommandLine)

logs.InitLogs()
if err := logsapi.ValidateAndApply(loggingConfig, featureGate); err != nil {
klog.Fatalf("Failed to validate and apply logging configuration: %v", err)
Expand Down Expand Up @@ -744,7 +745,7 @@ func defaultLeaderElectionConfiguration() componentbaseconfig.LeaderElectionConf
RenewDeadline: metav1.Duration{Duration: defaultRenewDeadline},
RetryPeriod: metav1.Duration{Duration: defaultRetryPeriod},
ResourceLock: resourcelock.LeasesResourceLock,
ResourceName: "cluster-autoscaler",
ResourceName: *leaseResourceName,
}
}

Expand Down

0 comments on commit bc49822

Please sign in to comment.