kube-proxy.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // CAUTION: If you update code in this file, you may need to also update code
  14. // in contrib/mesos/cmd/km/kube-proxy.go
  15. package main
  16. import (
  17. "k8s.io/kubernetes/cmd/kube-proxy/app"
  18. "k8s.io/kubernetes/cmd/kube-proxy/app/options"
  19. "k8s.io/kubernetes/pkg/healthz"
  20. )
  21. func init() {
  22. healthz.DefaultHealthz()
  23. }
  24. // NewKubeProxy creates a new hyperkube Server object that includes the
  25. // description and flags.
  26. func NewKubeProxy() *Server {
  27. config := options.NewProxyConfig()
  28. hks := Server{
  29. SimpleUsage: "proxy",
  30. Long: `The Kubernetes proxy server is responsible for taking traffic directed at
  31. services and forwarding it to the appropriate pods. It generally runs on
  32. nodes next to the Kubelet and proxies traffic from local pods to remote pods.
  33. It is also used when handling incoming external traffic.`,
  34. }
  35. config.AddFlags(hks.Flags())
  36. hks.Run = func(_ *Server, _ []string) error {
  37. s, err := app.NewProxyServerDefault(config)
  38. if err != nil {
  39. return err
  40. }
  41. return s.Run()
  42. }
  43. return &hks
  44. }