diff --git a/plugin/cmd/kube-scheduler/app/server.go b/plugin/cmd/kube-scheduler/app/server.go index 93982f898e3..68f8dad3c37 100644 --- a/plugin/cmd/kube-scheduler/app/server.go +++ b/plugin/cmd/kube-scheduler/app/server.go @@ -70,6 +70,7 @@ import ( "github.com/golang/glog" "github.com/spf13/cobra" "github.com/spf13/pflag" + utilflag "k8s.io/apiserver/pkg/util/flag" "github.com/prometheus/client_golang/prometheus" ) @@ -342,8 +343,8 @@ through the API as necessary.`, glog.Fatalf("unable to apply config defaults: %v", err) } - flags := cmd.Flags() - AddFlags(opts, flags) + AddFlags(opts, pflag.CommandLine) + utilflag.InitFlags() cmd.MarkFlagFilename("config", "yaml", "yml", "json") diff --git a/plugin/cmd/kube-scheduler/scheduler.go b/plugin/cmd/kube-scheduler/scheduler.go index 07ab2ca1168..f9e93db9c8c 100644 --- a/plugin/cmd/kube-scheduler/scheduler.go +++ b/plugin/cmd/kube-scheduler/scheduler.go @@ -17,12 +17,8 @@ limitations under the License. package main import ( - goflag "flag" "os" - "github.com/spf13/pflag" - - utilflag "k8s.io/apiserver/pkg/util/flag" "k8s.io/apiserver/pkg/util/logs" _ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration @@ -32,12 +28,6 @@ import ( func main() { command := app.NewSchedulerCommand() - // TODO: once we switch everything over to Cobra commands, we can go back to calling - // utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the - // normalize func and add the go flag set by hand. - pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) - pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) - // utilflag.InitFlags() logs.InitLogs() defer logs.FlushLogs()