本文整理汇总了Golang中k8s/io/kubernetes/pkg/util/flag.InitFlags函数的典型用法代码示例。如果您正苦于以下问题:Golang InitFlags函数的具体用法?Golang InitFlags怎么用?Golang InitFlags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitFlags函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
leaderElection := kube_leaderelection.DefaultLeaderElectionConfiguration()
leaderElection.LeaderElect = true
kube_leaderelection.BindFlags(&leaderElection, pflag.CommandLine)
flag.Var(&nodeGroupsFlag, "nodes", "sets min,max size and other configuration data for a node group in a format accepted by cloud provider."+
"Can be used multiple times. Format: <min>:<max>:<other...>")
kube_flag.InitFlags()
glog.Infof("Cluster Autoscaler %s", ClusterAutoscalerVersion)
correctEstimator := false
for _, availableEstimator := range AvailableEstimators {
if *estimatorFlag == availableEstimator {
correctEstimator = true
}
}
if !correctEstimator {
glog.Fatalf("Unrecognized estimator: %v", *estimatorFlag)
}
go func() {
http.Handle("/metrics", prometheus.Handler())
err := http.ListenAndServe(*address, nil)
glog.Fatalf("Failed to start metrics: %v", err)
}()
if !leaderElection.LeaderElect {
run(nil)
} else {
id, err := os.Hostname()
if err != nil {
glog.Fatalf("Unable to get hostname: %v", err)
}
kubeClient := createKubeClient()
kube_leaderelection.RunOrDie(kube_leaderelection.LeaderElectionConfig{
Lock: &resourcelock.EndpointsLock{
EndpointsMeta: apiv1.ObjectMeta{
Namespace: "kube-system",
Name: "cluster-autoscaler",
},
Client: kubeClient,
LockConfig: resourcelock.ResourceLockConfig{
Identity: id,
EventRecorder: createEventRecorder(kubeClient),
},
},
LeaseDuration: leaderElection.LeaseDuration.Duration,
RenewDeadline: leaderElection.RenewDeadline.Duration,
RetryPeriod: leaderElection.RetryPeriod.Duration,
Callbacks: kube_leaderelection.LeaderCallbacks{
OnStartedLeading: run,
OnStoppedLeading: func() {
glog.Fatalf("lost master")
},
},
})
}
}
示例2: main
func main() {
config := HollowNodeConfig{}
config.addFlags(pflag.CommandLine)
flag.InitFlags()
if !knownMorphs.Has(config.Morph) {
glog.Fatalf("Unknown morph: %v. Allowed values: %v", config.Morph, knownMorphs.List())
}
// create a client to communicate with API server.
clientConfig, err := config.createClientConfigFromFile()
if err != nil {
glog.Fatalf("Failed to create a ClientConfig: %v. Exiting.", err)
}
cl, err := client.New(clientConfig)
if err != nil {
glog.Fatalf("Failed to create a Client: %v. Exiting.", err)
}
clientset, err := internalclientset.NewForConfig(clientConfig)
if err != nil {
glog.Fatalf("Failed to create a ClientSet: %v. Exiting.", err)
}
if config.Morph == "kubelet" {
cadvisorInterface := new(cadvisortest.Fake)
containerManager := cm.NewStubContainerManager()
fakeDockerClient := dockertools.NewFakeDockerClient()
fakeDockerClient.EnableSleep = true
hollowKubelet := kubemark.NewHollowKubelet(
config.NodeName,
clientset,
cadvisorInterface,
fakeDockerClient,
config.KubeletPort,
config.KubeletReadOnlyPort,
containerManager,
maxPods,
podsPerCore,
)
hollowKubelet.Run()
}
if config.Morph == "proxy" {
eventBroadcaster := record.NewBroadcaster()
recorder := eventBroadcaster.NewRecorder(api.EventSource{Component: "kube-proxy", Host: config.NodeName})
iptInterface := fakeiptables.NewFake()
serviceConfig := proxyconfig.NewServiceConfig()
serviceConfig.RegisterHandler(&kubemark.FakeProxyHandler{})
endpointsConfig := proxyconfig.NewEndpointsConfig()
endpointsConfig.RegisterHandler(&kubemark.FakeProxyHandler{})
hollowProxy := kubemark.NewHollowProxyOrDie(config.NodeName, cl, endpointsConfig, serviceConfig, iptInterface, eventBroadcaster, recorder)
hollowProxy.Run()
}
}
示例3: main
func main() {
opt := options.NewHeapsterRunOptions()
opt.AddFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
setMaxProcs(opt)
glog.Infof(strings.Join(os.Args, " "))
glog.Infof("Heapster version %v", version.HeapsterVersion)
if err := validateFlags(opt); err != nil {
glog.Fatal(err)
}
kubernetesUrl, err := getKubernetesAddress(opt.Sources)
if err != nil {
glog.Fatalf("Failed to get kubernetes address: %v", err)
}
sourceManager := createSourceManagerOrDie(opt.Sources)
sinkManager, metricSink, historicalSource := createAndInitSinksOrDie(opt.Sinks, opt.HistoricalSource)
podLister, nodeLister := getListersOrDie(kubernetesUrl)
dataProcessors := createDataProcessorsOrDie(kubernetesUrl, podLister)
man, err := manager.NewManager(sourceManager, dataProcessors, sinkManager,
opt.MetricResolution, manager.DefaultScrapeOffset, manager.DefaultMaxParallelism)
if err != nil {
glog.Fatalf("Failed to create main manager: %v", err)
}
man.Start()
if opt.EnableAPIServer {
// Run API server in a separate goroutine
createAndRunAPIServer(opt, metricSink, nodeLister, podLister)
}
mux := http.NewServeMux()
promHandler := prometheus.Handler()
handler := setupHandlers(metricSink, podLister, nodeLister, historicalSource)
healthz.InstallHandler(mux, healthzChecker(metricSink))
addr := fmt.Sprintf("%s:%d", opt.Ip, opt.Port)
glog.Infof("Starting heapster on port %d", opt.Port)
if len(opt.TLSCertFile) > 0 && len(opt.TLSKeyFile) > 0 {
startSecureServing(opt, handler, promHandler, mux, addr)
} else {
mux.Handle("/", handler)
mux.Handle("/metrics", promHandler)
glog.Fatal(http.ListenAndServe(addr, mux))
}
}
示例4: main
func main() {
serverRunOptions := apiserver.NewServerRunOptions()
// Parse command line flags.
serverRunOptions.AddFlags(pflag.CommandLine)
flag.InitFlags()
if err := apiserver.Run(serverRunOptions); err != nil {
glog.Fatalf("Error in bringing up the server: %v", err)
}
}
示例5: main
func main() {
serverRunOptions := apiserver.NewServerRunOptions()
// Parse command line flags.
serverRunOptions.AddUniversalFlags(pflag.CommandLine)
serverRunOptions.AddEtcdStorageFlags(pflag.CommandLine)
flag.InitFlags()
if err := apiserver.Run(serverRunOptions, wait.NeverStop); err != nil {
glog.Fatalf("Error in bringing up the server: %v", err)
}
}
示例6: main
func main() {
s := options.NewSchedulerServer()
s.AddFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
app.Run(s)
}
示例7: main
func main() {
config := options.NewKubeDNSConfig()
config.AddFlags(pflag.CommandLine)
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()
verflag.PrintAndExitIfRequested()
server := app.NewKubeDNSServerDefault(config)
server.Run()
}
示例8: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
s := options.NewSchedulerServer()
s.AddFlags(pflag.CommandLine)
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()
verflag.PrintAndExitIfRequested()
app.Run(s)
}
示例9: main
func main() {
s := options.NewSchedulerServer()
s.AddFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
if err := app.Run(s); err != nil {
glog.Fatalf("scheduler app failed to run: %v", err)
}
}
示例10: main
func main() {
config := options.NewKubeDNSConfig()
config.AddFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
glog.V(0).Infof("version: %+v", version.Get())
server := app.NewKubeDNSServerDefault(config)
server.Run()
}
示例11: main
func main() {
options := server.NewOptions()
configureFlags(options, pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
glog.Infof("dnsmasq-metrics v%s", version.VERSION)
verflag.PrintAndExitIfRequested()
server := server.NewServer()
server.Run(options)
}
示例12: main
func main() {
s := options.NewCMServer()
s.AddFlags(pflag.CommandLine, app.KnownControllers(), app.ControllersDisabledByDefault.List())
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
if err := app.Run(s); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
示例13: main
func main() {
s := options.NewCMServer()
s.AddFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
if err := app.Run(s); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
示例14: main
func main() {
s := service.NewSchedulerServer()
s.AddStandaloneFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
if err := s.Run(hyperkube.Nil(), pflag.CommandLine.Args()); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}
}
示例15: main
func main() {
serverRunOptions := apiserver.NewServerRunOptions()
// Parse command line flags.
serverRunOptions.GenericServerRunOptions.AddUniversalFlags(pflag.CommandLine)
serverRunOptions.Etcd.AddFlags(pflag.CommandLine)
serverRunOptions.SecureServing.AddFlags(pflag.CommandLine)
serverRunOptions.SecureServing.AddDeprecatedFlags(pflag.CommandLine)
serverRunOptions.InsecureServing.AddFlags(pflag.CommandLine)
serverRunOptions.InsecureServing.AddDeprecatedFlags(pflag.CommandLine)
flag.InitFlags()
if err := serverRunOptions.Run(wait.NeverStop); err != nil {
glog.Fatalf("Error in bringing up the server: %v", err)
}
}