controller-manager.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. Copyright 2016 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. // The external controller manager is responsible for running controller loops that
  14. // are cloud provider dependent. It uses the API to listen to new events on resources.
  15. package main
  16. import (
  17. "fmt"
  18. "math/rand"
  19. "os"
  20. "time"
  21. "k8s.io/component-base/logs"
  22. "k8s.io/kubernetes/cmd/cloud-controller-manager/app"
  23. // NOTE: Importing all in-tree cloud-providers is not required when
  24. // implementing an out-of-tree cloud-provider.
  25. _ "k8s.io/kubernetes/pkg/cloudprovider/providers"
  26. _ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugins
  27. _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
  28. )
  29. func main() {
  30. rand.Seed(time.Now().UnixNano())
  31. command := app.NewCloudControllerManagerCommand()
  32. // TODO: once we switch everything over to Cobra commands, we can go back to calling
  33. // utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the
  34. // normalize func and add the go flag set by hand.
  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. }