2015-02-07 22:01:54 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2015 The Kubernetes Authors.
|
2015-02-07 22:01:54 +00:00
|
|
|
|
|
|
|
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 (
|
2017-01-17 10:38:25 +00:00
|
|
|
"k8s.io/apiserver/pkg/server/healthz"
|
2015-12-25 00:27:57 +00:00
|
|
|
"k8s.io/kubernetes/cmd/kube-proxy/app"
|
|
|
|
"k8s.io/kubernetes/cmd/kube-proxy/app/options"
|
2015-02-07 22:01:54 +00:00
|
|
|
)
|
|
|
|
|
2016-02-23 14:47:23 +00:00
|
|
|
func init() {
|
|
|
|
healthz.DefaultHealthz()
|
|
|
|
}
|
|
|
|
|
2015-02-07 22:01:54 +00:00
|
|
|
// NewKubeProxy creates a new hyperkube Server object that includes the
|
|
|
|
// description and flags.
|
2015-02-08 04:35:02 +00:00
|
|
|
func NewKubeProxy() *Server {
|
2015-12-25 00:27:57 +00:00
|
|
|
config := options.NewProxyConfig()
|
2015-02-07 22:01:54 +00:00
|
|
|
|
2015-02-08 04:35:02 +00:00
|
|
|
hks := Server{
|
2017-02-06 15:05:42 +00:00
|
|
|
name: "proxy",
|
|
|
|
AlternativeName: "kube-proxy",
|
|
|
|
SimpleUsage: "proxy",
|
2015-02-07 22:01:54 +00:00
|
|
|
Long: `The Kubernetes proxy server is responsible for taking traffic directed at
|
2015-09-21 10:05:22 +00:00
|
|
|
services and forwarding it to the appropriate pods. It generally runs on
|
2015-02-07 22:01:54 +00:00
|
|
|
nodes next to the Kubelet and proxies traffic from local pods to remote pods.
|
|
|
|
It is also used when handling incoming external traffic.`,
|
|
|
|
}
|
2015-09-21 10:05:22 +00:00
|
|
|
|
|
|
|
config.AddFlags(hks.Flags())
|
|
|
|
|
2015-12-25 00:27:57 +00:00
|
|
|
hks.Run = func(_ *Server, _ []string) error {
|
|
|
|
s, err := app.NewProxyServerDefault(config)
|
2015-09-28 16:52:39 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-12-25 00:27:57 +00:00
|
|
|
return s.Run()
|
2015-09-21 10:05:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-07 22:01:54 +00:00
|
|
|
return &hks
|
|
|
|
}
|