Share KM_* constants

pull/6/head
Dr. Stefan Schimanski 2015-07-28 17:12:22 +02:00
parent 0ebf1811f3
commit 1200125137
10 changed files with 44 additions and 20 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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"
)

View File

@ -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")