diff --git a/cmd/hyperkube/kube-proxy.go b/cmd/hyperkube/kube-proxy.go index ffaa1a54c13..98d8febe72f 100644 --- a/cmd/hyperkube/kube-proxy.go +++ b/cmd/hyperkube/kube-proxy.go @@ -19,6 +19,7 @@ limitations under the License. package main import ( + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" kubeproxy "github.com/GoogleCloudPlatform/kubernetes/cmd/kube-proxy/app" ) @@ -28,7 +29,7 @@ func NewKubeProxy() *Server { s := kubeproxy.NewProxyServer() hks := Server{ - SimpleUsage: "proxy", + SimpleUsage: hyperkube.KM_PROXY, Long: `The Kubernetes proxy server is responsible for taking traffic directed at services and forwarding it to the appropriate pods. It generally runs on nodes next to the Kubelet and proxies traffic from local pods to remote pods. diff --git a/cmd/hyperkube/kube-scheduler.go b/cmd/hyperkube/kube-scheduler.go index ededc4ed8ae..9af65e14d03 100644 --- a/cmd/hyperkube/kube-scheduler.go +++ b/cmd/hyperkube/kube-scheduler.go @@ -19,6 +19,7 @@ limitations under the License. package main import ( + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" scheduler "github.com/GoogleCloudPlatform/kubernetes/plugin/cmd/kube-scheduler/app" ) @@ -28,7 +29,7 @@ func NewScheduler() *Server { s := scheduler.NewSchedulerServer() hks := Server{ - SimpleUsage: "scheduler", + SimpleUsage: hyperkube.KM_SCHEDULER, Long: "Implements a Kubernetes scheduler. This will assign pods to kubelets based on capacity and constraints.", Run: func(_ *Server, args []string) error { return s.Run(args) diff --git a/contrib/mesos/cmd/km/k8sm-controllermanager.go b/contrib/mesos/cmd/km/k8sm-controllermanager.go index db87b84bf9d..f9a8985a17f 100644 --- a/contrib/mesos/cmd/km/k8sm-controllermanager.go +++ b/contrib/mesos/cmd/km/k8sm-controllermanager.go @@ -19,6 +19,7 @@ package main import ( "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/controllermanager" + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" ) // NewHyperkubeServer creates a new hyperkube Server object that includes the @@ -27,7 +28,7 @@ func NewControllerManager() *Server { s := controllermanager.NewCMServer() hks := Server{ - SimpleUsage: "controller-manager", + SimpleUsage: hyperkube.KM_CONTROLLER_MANAGER, Long: "A server that runs a set of active components. This includes replication controllers, service endpoints and nodes.", Run: func(_ *Server, args []string) error { return s.Run(args) diff --git a/contrib/mesos/cmd/km/k8sm-executor.go b/contrib/mesos/cmd/km/k8sm-executor.go index 8c90a694e74..72db942816d 100644 --- a/contrib/mesos/cmd/km/k8sm-executor.go +++ b/contrib/mesos/cmd/km/k8sm-executor.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/executor/service" ) @@ -25,7 +26,7 @@ import ( func NewKubeletExecutor() *Server { s := service.NewHyperKubeletExecutorServer() hks := Server{ - SimpleUsage: "executor", + SimpleUsage: hyperkube.KM_EXECUTOR, Long: `The kubelet-executor binary is responsible for maintaining a set of containers on a particular node. It syncs data from a specialized Mesos source that tracks task launches and kills. It then queries Docker to see what is currently diff --git a/contrib/mesos/cmd/km/k8sm-scheduler.go b/contrib/mesos/cmd/km/k8sm-scheduler.go index ba759dc4a00..9d291f087fc 100644 --- a/contrib/mesos/cmd/km/k8sm-scheduler.go +++ b/contrib/mesos/cmd/km/k8sm-scheduler.go @@ -18,6 +18,7 @@ limitations under the License. package main import ( + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/service" ) @@ -27,7 +28,7 @@ func NewScheduler() *Server { s := service.NewSchedulerServer() hks := Server{ - SimpleUsage: "scheduler", + SimpleUsage: hyperkube.KM_SCHEDULER, Long: `Implements the Kubernetes-Mesos scheduler. This will launch Mesos tasks which results in pods assigned to kubelets based on capacity and constraints.`, Run: func(hks *Server, args []string) error { diff --git a/contrib/mesos/cmd/km/kube-apiserver.go b/contrib/mesos/cmd/km/kube-apiserver.go index 81ed2d83336..bc15dc2eae6 100644 --- a/contrib/mesos/cmd/km/kube-apiserver.go +++ b/contrib/mesos/cmd/km/kube-apiserver.go @@ -18,6 +18,7 @@ limitations under the License. package main import ( + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" kubeapiserver "github.com/GoogleCloudPlatform/kubernetes/cmd/kube-apiserver/app" ) @@ -27,7 +28,7 @@ func NewKubeAPIServer() *Server { s := kubeapiserver.NewAPIServer() hks := Server{ - SimpleUsage: "apiserver", + SimpleUsage: hyperkube.KM_APISERVER, Long: "The main API entrypoint and interface to the storage system. The API server is also the focal point for all authorization decisions.", Run: func(_ *Server, args []string) error { return s.Run(args) diff --git a/contrib/mesos/cmd/km/kube-proxy.go b/contrib/mesos/cmd/km/kube-proxy.go index be7522913bc..f7f497afef2 100644 --- a/contrib/mesos/cmd/km/kube-proxy.go +++ b/contrib/mesos/cmd/km/kube-proxy.go @@ -18,6 +18,7 @@ limitations under the License. package main import ( + "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/hyperkube" kubeproxy "github.com/GoogleCloudPlatform/kubernetes/cmd/kube-proxy/app" ) @@ -27,7 +28,7 @@ func NewKubeProxy() *Server { s := kubeproxy.NewProxyServer() hks := Server{ - SimpleUsage: "proxy", + SimpleUsage: hyperkube.KM_PROXY, Long: `The Kubernetes proxy server is responsible for taking traffic directed at services and forwarding it to the appropriate pods. It generally runs on nodes next to the Kubelet and proxies traffic from local pods to remote pods. diff --git a/contrib/mesos/pkg/executor/service/service.go b/contrib/mesos/pkg/executor/service/service.go index 66a29a9e31c..021c9482b16 100644 --- a/contrib/mesos/pkg/executor/service/service.go +++ b/contrib/mesos/pkg/executor/service/service.go @@ -502,14 +502,12 @@ func (kl *kubeletExecutor) ListenAndServe(address net.IP, port uint, tlsOptions // this function blocks as long as the proxy service is running; intended to be // executed asynchronously. func (kl *kubeletExecutor) runProxyService() { - log.Infof("Starting proxy process...") - const KM_PROXY = "proxy" //TODO(jdef) constant should be shared with km package args := []string{} - if kl.hks.FindServer(KM_PROXY) { - args = append(args, KM_PROXY) + if kl.hks.FindServer(hyperkube.KM_PROXY) { + args = append(args, hyperkube.KM_PROXY) log.V(1).Infof("attempting to using km proxy service") } else if _, err := os.Stat(kl.proxyExec); os.IsNotExist(err) { log.Errorf("failed to locate proxy executable at '%v' and km not present: %v", kl.proxyExec, err) diff --git a/contrib/mesos/pkg/hyperkube/hyperkube.go b/contrib/mesos/pkg/hyperkube/hyperkube.go new file mode 100644 index 00000000000..4de62e378cf --- /dev/null +++ b/contrib/mesos/pkg/hyperkube/hyperkube.go @@ -0,0 +1,25 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package hyperkube + +const ( + KM_APISERVER = "apiserver" + KM_CONTROLLER_MANAGER = "controller-manager" + KM_EXECUTOR = "executor" + KM_PROXY = "proxy" + KM_SCHEDULER = "scheduler" +) diff --git a/contrib/mesos/pkg/scheduler/service/service.go b/contrib/mesos/pkg/scheduler/service/service.go index 2df05c651e7..cfcfe1dd0ab 100644 --- a/contrib/mesos/pkg/scheduler/service/service.go +++ b/contrib/mesos/pkg/scheduler/service/service.go @@ -279,17 +279,11 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E Shell: proto.Bool(false), } - //TODO(jdef) these should be shared constants with km - const ( - KM_EXECUTOR = "executor" - KM_PROXY = "proxy" - ) - if s.ExecutorPath != "" { uri, executorCmd := s.serveFrameworkArtifact(s.ExecutorPath) ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(true)}) ci.Value = proto.String(fmt.Sprintf("./%s", executorCmd)) - } else if !hks.FindServer(KM_EXECUTOR) { + } else if !hks.FindServer(hyperkube.KM_EXECUTOR) { return nil, nil, fmt.Errorf("either run this scheduler via km or else --executor-path is required") } else { if strings.Index(s.KMPath, "://") > 0 { @@ -307,14 +301,14 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(true)}) ci.Value = proto.String(fmt.Sprintf("./%s", kmCmd)) } - ci.Arguments = append(ci.Arguments, KM_EXECUTOR) + ci.Arguments = append(ci.Arguments, hyperkube.KM_MINION) } if s.ProxyPath != "" { uri, proxyCmd := s.serveFrameworkArtifact(s.ProxyPath) ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(true)}) ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-exec=./%s", proxyCmd)) - } else if !hks.FindServer(KM_PROXY) { + } else if !hks.FindServer(hyperkube.KM_PROXY) { return nil, nil, fmt.Errorf("either run this scheduler via km or else --proxy-path is required") } else if s.ExecutorPath != "" { return nil, nil, fmt.Errorf("proxy can only use km binary if executor does the same")