add kube-aggregator to hyperkube

pull/6/head
deads2k 2017-02-16 14:44:04 -05:00
parent 2509ab0c7a
commit 612a8fafb8
5 changed files with 81 additions and 16 deletions

View File

@ -32,6 +32,7 @@ go_library(
"federation-apiserver.go", "federation-apiserver.go",
"federation-controller-manager.go", "federation-controller-manager.go",
"hyperkube.go", "hyperkube.go",
"kube-aggregator.go",
"kube-apiserver.go", "kube-apiserver.go",
"kube-controller-manager.go", "kube-controller-manager.go",
"kube-proxy.go", "kube-proxy.go",
@ -67,6 +68,7 @@ go_library(
"//vendor:k8s.io/apiserver/pkg/server/healthz", "//vendor:k8s.io/apiserver/pkg/server/healthz",
"//vendor:k8s.io/apiserver/pkg/util/flag", "//vendor:k8s.io/apiserver/pkg/util/flag",
"//vendor:k8s.io/apiserver/pkg/util/logs", "//vendor:k8s.io/apiserver/pkg/util/logs",
"//vendor:k8s.io/kube-aggregator/pkg/cmd/server",
], ],
) )

View File

@ -0,0 +1,51 @@
/*
Copyright 2017 The Kubernetes Authors.
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 main
import (
"os"
"k8s.io/kube-aggregator/pkg/cmd/server"
)
// NewKubeAggregator creates a new hyperkube Server object that includes the
// description and flags.
func NewKubeAggregator() *Server {
o := server.NewDefaultOptions(os.Stdout, os.Stderr)
hks := Server{
name: "aggregator",
AlternativeName: "kube-aggregator",
SimpleUsage: "aggregator",
Long: "Aggregator for Kubernetes-style API servers: dynamic registration, discovery summarization, secure proxy.",
Run: func(_ *Server, args []string) error {
if err := o.Complete(); err != nil {
return err
}
if err := o.Validate(args); err != nil {
return err
}
if err := o.RunAggregator(); err != nil {
return err
}
return nil
},
}
o.AddFlags(hks.Flags())
return &hks
}

View File

@ -38,6 +38,7 @@ func main() {
hk.AddServer(NewScheduler()) hk.AddServer(NewScheduler())
hk.AddServer(NewKubelet()) hk.AddServer(NewKubelet())
hk.AddServer(NewKubeProxy()) hk.AddServer(NewKubeProxy())
hk.AddServer(NewKubeAggregator())
//Federation servers //Federation servers
hk.AddServer(NewFederationAPIServer()) hk.AddServer(NewFederationAPIServer())

View File

@ -22,6 +22,7 @@ import (
"io/ioutil" "io/ioutil"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
@ -32,9 +33,8 @@ import (
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
"k8s.io/kube-aggregator/pkg/apiserver"
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1" "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1"
"k8s.io/kube-aggregator/pkg/apiserver"
) )
const defaultEtcdPathPrefix = "/registry/kube-aggregator.kubernetes.io/" const defaultEtcdPathPrefix = "/registry/kube-aggregator.kubernetes.io/"
@ -55,15 +55,9 @@ type AggregatorOptions struct {
StdErr io.Writer StdErr io.Writer
} }
// NewCommandStartMaster provides a CLI handler for 'start master' command // NewCommandStartAggregator provides a CLI handler for 'start master' command
func NewCommandStartAggregator(out, err io.Writer) *cobra.Command { func NewCommandStartAggregator(out, err io.Writer) *cobra.Command {
o := &AggregatorOptions{ o := NewDefaultOptions(out, err)
RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, api.Scheme, api.Codecs.LegacyCodec(v1alpha1.SchemeGroupVersion)),
StdOut: out,
StdErr: err,
}
o.RecommendedOptions.SecureServing.ServingOptions.BindPort = 443
cmd := &cobra.Command{ cmd := &cobra.Command{
Short: "Launch a API aggregator and proxy server", Short: "Launch a API aggregator and proxy server",
@ -82,14 +76,30 @@ func NewCommandStartAggregator(out, err io.Writer) *cobra.Command {
}, },
} }
flags := cmd.Flags() o.AddFlags(cmd.Flags())
o.RecommendedOptions.AddFlags(flags) return cmd
flags.StringVar(&o.ProxyClientCertFile, "proxy-client-cert-file", o.ProxyClientCertFile, "client certificate used identify the proxy to the API server") }
flags.StringVar(&o.ProxyClientKeyFile, "proxy-client-key-file", o.ProxyClientKeyFile, "client certificate key used identify the proxy to the API server")
flags.StringVar(&o.CoreAPIKubeconfig, "core-kubeconfig", o.CoreAPIKubeconfig, ""+ // AddFlags is necessary because hyperkube doesn't work using cobra, so we have to have different registration and execution paths
func (o *AggregatorOptions) AddFlags(fs *pflag.FlagSet) {
o.RecommendedOptions.AddFlags(fs)
fs.StringVar(&o.ProxyClientCertFile, "proxy-client-cert-file", o.ProxyClientCertFile, "client certificate used identify the proxy to the API server")
fs.StringVar(&o.ProxyClientKeyFile, "proxy-client-key-file", o.ProxyClientKeyFile, "client certificate key used identify the proxy to the API server")
fs.StringVar(&o.CoreAPIKubeconfig, "core-kubeconfig", o.CoreAPIKubeconfig, ""+
"kubeconfig file pointing at the 'core' kubernetes server with enough rights to get,list,watch "+ "kubeconfig file pointing at the 'core' kubernetes server with enough rights to get,list,watch "+
" services,endpoints. If not set, the in-cluster config is used") " services,endpoints. If not set, the in-cluster config is used")
return cmd }
// NewDefaultOptions builds a "normal" set of options. You wouldn't normally expose this, but hyperkube isn't cobra compatible
func NewDefaultOptions(out, err io.Writer) *AggregatorOptions {
o := &AggregatorOptions{
RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, api.Scheme, api.Codecs.LegacyCodec(v1alpha1.SchemeGroupVersion)),
StdOut: out,
StdErr: err,
}
o.RecommendedOptions.SecureServing.ServingOptions.BindPort = 443
return o
} }
func (o AggregatorOptions) Validate(args []string) error { func (o AggregatorOptions) Validate(args []string) error {

1
vendor/BUILD vendored
View File

@ -16793,6 +16793,7 @@ go_library(
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//vendor:github.com/spf13/cobra", "//vendor:github.com/spf13/cobra",
"//vendor:github.com/spf13/pflag",
"//vendor:k8s.io/apimachinery/pkg/util/sets", "//vendor:k8s.io/apimachinery/pkg/util/sets",
"//vendor:k8s.io/apimachinery/pkg/util/wait", "//vendor:k8s.io/apimachinery/pkg/util/wait",
"//vendor:k8s.io/apiserver/pkg/server", "//vendor:k8s.io/apiserver/pkg/server",