Commit 6bdede69 authored by Joe Beda's avatar Joe Beda

Convert kube-apiserver to hyperkube.

Part of #108. Also: * Added hyperkube cmd (not built by default yet). * Added version support to hyperkube * Remove health_check_minions flag from apiserver as it is no longer used with #3733
parent 6432b563
/*
Copyright 2014 Google Inc. 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.
*/
// A binary that can morph into all of the other kubernetes binaries. You can
// also soft-link to it busybox style.
package main
import (
"os"
"github.com/GoogleCloudPlatform/kubernetes/pkg/hyperkube"
apiserver "github.com/GoogleCloudPlatform/kubernetes/pkg/master/server"
)
func main() {
hk := hyperkube.HyperKube{
Name: "hyperkube",
Long: "This is an all-in-one binary that can run any of the various Kubernetes servers.",
}
hk.AddServer(apiserver.NewHyperkubeServer())
hk.RunToExit(os.Args)
}
......@@ -38,9 +38,6 @@ The the kube-apiserver several options.
**--etcd_servers**=[]
List of etcd servers to watch (http://ip:port), comma separated
**--health_check_minions**=
If true, health check minions and filter unhealthy ones. Default true.
**--log_backtrace_at=**:0
when logging hits line file:N, emit a stack trace
......
......@@ -26,6 +26,7 @@ import (
"path"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version/verflag"
"github.com/spf13/pflag"
)
......@@ -128,6 +129,9 @@ func (hk *HyperKube) Run(args []string) error {
hk.Usage()
return err
}
verflag.PrintAndExitIfRequested()
args = baseFlags.Args()
if len(args) > 0 && len(args[0]) > 0 {
serverName = args[0]
......@@ -135,7 +139,7 @@ func (hk *HyperKube) Run(args []string) error {
args = args[1:]
} else {
err = errors.New("No server specified")
hk.Println("Error", err)
hk.Printf("Error: %v\n\n", err)
hk.Usage()
return err
}
......@@ -143,7 +147,7 @@ func (hk *HyperKube) Run(args []string) error {
s, err := hk.FindServer(serverName)
if err != nil {
hk.Println("Error:", err)
hk.Printf("Error: %v\n\n", err)
hk.Usage()
return err
}
......@@ -152,13 +156,17 @@ func (hk *HyperKube) Run(args []string) error {
err = s.Flags().Parse(args)
if err != nil || hk.helpFlagVal {
if err != nil {
hk.Println("Error:", err)
hk.Printf("Error: %v\n\n", err)
}
s.Usage()
return err
}
verflag.PrintAndExitIfRequested()
util.InitLogs()
defer util.FlushLogs()
err = s.Run(s, s.Flags().Args())
if err != nil {
hk.Println("Error:", err)
......@@ -167,6 +175,15 @@ func (hk *HyperKube) Run(args []string) error {
return err
}
// RunToExit will run the hyperkube and then call os.Exit with an appropriate exit code.
func (hk *HyperKube) RunToExit(args []string) {
err := hk.Run(args)
if err != nil {
os.Exit(1)
}
os.Exit(0)
}
// Usage will write out a summary for all servers that this binary supports.
func (hk *HyperKube) Usage() {
tt := `{{if .Long}}{{.Long | trim | wrap ""}}
......
......@@ -38,7 +38,7 @@ type Server struct {
hk *HyperKube
}
// FullUsage returns the full usage string including all of the flags.
// Usage returns the full usage string including all of the flags.
func (s *Server) Usage() error {
tt := `{{if .Long}}{{.Long | trim | wrap ""}}
{{end}}Usage:
......
......@@ -14,18 +14,20 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package server
// This file exists to force the desired plugin implementations to be linked.
// This should probably be part of some configuration fed into the build for a
// given binary target.
import (
// Cloud providers
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/aws"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/gce"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/openstack"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/ovirt"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
// Admission policies
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/admit"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/deny"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/limitranger"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment