forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scheduler.go
48 lines (37 loc) · 1.12 KB
/
scheduler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package kubernetes
import (
"fmt"
"io"
"os"
"github.com/spf13/cobra"
kflag "k8s.io/kubernetes/pkg/util/flag"
"k8s.io/kubernetes/pkg/util/logs"
schedulerapp "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app"
scheduleroptions "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app/options"
)
const schedulerLong = `
Start Kubernetes scheduler
This command launches an instance of the Kubernetes scheduler (kube-scheduler).`
// NewSchedulerCommand provides a CLI handler for the 'scheduler' command
func NewSchedulerCommand(name, fullName string, out io.Writer) *cobra.Command {
schedulerOptions := scheduleroptions.NewSchedulerServer()
cmd := &cobra.Command{
Use: name,
Short: "Launch Kubernetes scheduler (kube-scheduler)",
Long: schedulerLong,
Run: func(c *cobra.Command, args []string) {
startProfiler()
logs.InitLogs()
defer logs.FlushLogs()
if err := schedulerapp.Run(schedulerOptions); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
},
}
cmd.SetOutput(out)
flags := cmd.Flags()
flags.SetNormalizeFunc(kflag.WordSepNormalizeFunc)
schedulerOptions.AddFlags(flags)
return cmd
}