proxy.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright 2014 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. package main
  14. import (
  15. goflag "flag"
  16. "fmt"
  17. "math/rand"
  18. "os"
  19. "time"
  20. "github.com/spf13/pflag"
  21. cliflag "k8s.io/component-base/cli/flag"
  22. "k8s.io/component-base/logs"
  23. "k8s.io/kubernetes/cmd/kube-proxy/app"
  24. _ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
  25. _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
  26. )
  27. func main() {
  28. rand.Seed(time.Now().UnixNano())
  29. command := app.NewProxyCommand()
  30. // TODO: once we switch everything over to Cobra commands, we can go back to calling
  31. // utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the
  32. // normalize func and add the go flag set by hand.
  33. pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
  34. pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
  35. // utilflag.InitFlags()
  36. logs.InitLogs()
  37. defer logs.FlushLogs()
  38. if err := command.Execute(); err != nil {
  39. fmt.Fprintf(os.Stderr, "error: %v\n", err)
  40. os.Exit(1)
  41. }
  42. }