From 5d0847585b775b142deed2df1518b5fe1bdd81d2 Mon Sep 17 00:00:00 2001 From: David Eads Date: Thu, 18 Jan 2018 09:52:46 -0500 Subject: [PATCH] handle scheduler without exposed ports --- cmd/kube-scheduler/app/server.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/kube-scheduler/app/server.go b/cmd/kube-scheduler/app/server.go index 0f0e1bf25e..22edbce65f 100644 --- a/cmd/kube-scheduler/app/server.go +++ b/cmd/kube-scheduler/app/server.go @@ -194,6 +194,7 @@ func (o *Options) applyDeprecatedHealthzAddressToConfig() { func (o *Options) applyDeprecatedHealthzPortToConfig() { if o.healthzPort == -1 { o.config.HealthzBindAddress = "" + o.config.MetricsBindAddress = "" return } @@ -374,10 +375,13 @@ func NewSchedulerServer(config *componentconfig.KubeSchedulerConfiguration, mast } // Configz registration. - if c, err := configz.New("componentconfig"); err == nil { - c.Set(config) - } else { - return nil, fmt.Errorf("unable to register configz: %s", err) + // only register if we're actually exposing it somewhere + if len(config.MetricsBindAddress) > 0 || len(config.HealthzBindAddress) > 0 { + if c, err := configz.New("componentconfig"); err == nil { + c.Set(config) + } else { + return nil, fmt.Errorf("unable to register configz: %s", err) + } } // Prepare some Kube clients. @@ -402,7 +406,7 @@ func NewSchedulerServer(config *componentconfig.KubeSchedulerConfiguration, mast // Prepare a healthz server. If the metrics bind address is the same as the // healthz bind address, consolidate the servers into one. var healthzServer *http.Server - if len(config.HealthzBindAddress) != 0 { + if len(config.HealthzBindAddress) > 0 { healthzServer = makeHealthzServer(config) }