forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kubernetes.go
56 lines (46 loc) · 1.74 KB
/
kubernetes.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
49
50
51
52
53
54
55
56
package kubernetes
import (
"fmt"
"io"
"net/http"
"runtime"
"github.com/golang/glog"
"github.com/spf13/cobra"
proxyapp "k8s.io/kubernetes/cmd/kube-proxy/app"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/oc/cli/cmd"
)
const kubernetesLong = `
Start Kubernetes server components
The primary Kubernetes server components can be started individually using their direct
arguments. No configuration settings will be used when launching these components.
`
func NewCommand(name, fullName string, out, errOut io.Writer) *cobra.Command {
cmds := &cobra.Command{
Use: name,
Short: "Kubernetes server components",
Long: fmt.Sprintf(kubernetesLong),
Run: kcmdutil.DefaultSubCommandRun(errOut),
}
cmds.AddCommand(NewAPIServerCommand("apiserver", fullName+" apiserver", out))
cmds.AddCommand(NewControllersCommand("controller-manager", fullName+" controller-manager", out))
cmds.AddCommand(NewKubeletCommand("kubelet", fullName+" kubelet", out))
cmds.AddCommand(proxyapp.NewProxyCommand())
cmds.AddCommand(NewSchedulerCommand("scheduler", fullName+" scheduler", out))
if "hyperkube" == fullName {
cmds.AddCommand(cmd.NewCmdVersion(fullName, nil, out, cmd.VersionOptions{}))
}
return cmds
}
func startProfiler() {
if cmdutil.Env("OPENSHIFT_PROFILE", "") == "web" {
go func() {
runtime.SetBlockProfileRate(1)
profilePort := cmdutil.Env("OPENSHIFT_PROFILE_PORT", "6060")
profileHost := cmdutil.Env("OPENSHIFT_PROFILE_HOST", "127.0.0.1")
glog.Infof(fmt.Sprintf("Starting profiling endpoint at http://%s:%s/debug/pprof/", profileHost, profilePort))
glog.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%s", profileHost, profilePort), nil))
}()
}
}