Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14eee1d

Browse files
committed
Enable HPA controller based on autoscaling/v1 api group
1 parent 4280eed commit 14eee1d

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

cmd/kube-controller-manager/app/controllermanager.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,6 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl
382382
// TODO: this needs to be dynamic so users don't have to restart their controller manager if they change the apiserver
383383
if containsVersion(versions, groupVersion) && found {
384384
glog.Infof("Starting %s apis", groupVersion)
385-
if containsResource(resources, "horizontalpodautoscalers") {
386-
glog.Infof("Starting horizontal pod controller.")
387-
hpaClient := client("horizontal-pod-autoscaler")
388-
metricsClient := metrics.NewHeapsterMetricsClient(
389-
hpaClient,
390-
metrics.DefaultHeapsterNamespace,
391-
metrics.DefaultHeapsterScheme,
392-
metrics.DefaultHeapsterService,
393-
metrics.DefaultHeapsterPort,
394-
)
395-
go podautoscaler.NewHorizontalController(hpaClient.Core(), hpaClient.Extensions(), hpaClient.Autoscaling(), metricsClient, s.HorizontalPodAutoscalerSyncPeriod.Duration).
396-
Run(wait.NeverStop)
397-
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))
398-
}
399385

400386
if containsResource(resources, "daemonsets") {
401387
glog.Infof("Starting daemon set controller")
@@ -426,6 +412,27 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl
426412
}
427413
}
428414

415+
groupVersion = "autoscaling/v1"
416+
resources, found = resourceMap[groupVersion]
417+
glog.Infof("Attempting to start horizontal pod autoscaler controller, full resource map %+v", resourceMap)
418+
if containsVersion(versions, groupVersion) && found {
419+
glog.Infof("Starting %s apis", groupVersion)
420+
if containsResource(resources, "horizontalpodautoscalers") {
421+
glog.Infof("Starting horizontal pod controller.")
422+
hpaClient := client("horizontal-pod-autoscaler")
423+
metricsClient := metrics.NewHeapsterMetricsClient(
424+
hpaClient,
425+
metrics.DefaultHeapsterNamespace,
426+
metrics.DefaultHeapsterScheme,
427+
metrics.DefaultHeapsterService,
428+
metrics.DefaultHeapsterPort,
429+
)
430+
go podautoscaler.NewHorizontalController(hpaClient.Core(), hpaClient.Extensions(), hpaClient.Autoscaling(), metricsClient, s.HorizontalPodAutoscalerSyncPeriod.Duration).
431+
Run(wait.NeverStop)
432+
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))
433+
}
434+
}
435+
429436
groupVersion = "policy/v1beta1"
430437
resources, found = resourceMap[groupVersion]
431438
glog.Infof("Attempting to start disruption controller, full resource map %+v", resourceMap)

0 commit comments

Comments
 (0)