當前位置: 首頁>>代碼示例>>Golang>>正文


Golang app.Run函數代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/cmd/kube-apiserver/app.Run函數的典型用法代碼示例。如果您正苦於以下問題:Golang Run函數的具體用法?Golang Run怎麽用?Golang Run使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Run函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewAPIServerCommand

// NewAPIServerCommand provides a CLI handler for the 'apiserver' command
func NewAPIServerCommand(name, fullName string, out io.Writer) *cobra.Command {
	apiServerOptions := apiserveroptions.NewAPIServer()

	cmd := &cobra.Command{
		Use:   name,
		Short: "Launch Kubernetes apiserver (kube-apiserver)",
		Long:  apiserverLong,
		Run: func(c *cobra.Command, args []string) {
			startProfiler()

			util.InitLogs()
			defer util.FlushLogs()

			if err := apiserverapp.Run(apiServerOptions); err != nil {
				fmt.Fprintf(os.Stderr, "%v\n", err)
				os.Exit(1)
			}
		},
	}
	cmd.SetOutput(out)

	flags := cmd.Flags()
	flags.SetNormalizeFunc(util.WordSepNormalizeFunc)
	flags.AddGoFlagSet(flag.CommandLine)
	apiServerOptions.AddFlags(flags)

	return cmd
}
開發者ID:asiainfoLDP,項目名稱:datafactory,代碼行數:29,代碼來源:apiserver.go

示例2: StartAPIServer

func StartAPIServer(lk LocalkubeServer) func() error {
	config := options.NewAPIServer()

	config.BindAddress = lk.APIServerAddress
	config.SecurePort = lk.APIServerPort
	config.InsecureBindAddress = lk.APIServerInsecureAddress
	config.InsecurePort = lk.APIServerInsecurePort

	config.ClientCAFile = lk.GetPublicKeyCertPath()
	config.TLSCertFile = lk.GetPublicKeyCertPath()
	config.TLSPrivateKeyFile = lk.GetPrivateKeyCertPath()
	config.AdmissionControl = "NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota"

	// use localkube etcd
	config.StorageConfig = storagebackend.Config{ServerList: KubeEtcdClientURLs}

	// set Service IP range
	config.ServiceClusterIPRange = lk.ServiceClusterIPRange

	// defaults from apiserver command
	config.EnableProfiling = true
	config.EnableWatchCache = true
	config.MinRequestTimeout = 1800

	config.AllowPrivileged = true

	return func() error {
		return apiserver.Run(config)
	}
}
開發者ID:tmrts,項目名稱:minikube,代碼行數:30,代碼來源:apiserver.go

示例3: Start

// Start starts the apiserver, returns when apiserver is ready.
func (a *APIServer) Start() error {
	config := options.NewServerRunOptions()
	config.Etcd.StorageConfig.ServerList = []string{getEtcdClientURL()}
	// TODO: Current setup of etcd in e2e-node tests doesn't support etcd v3
	// protocol. We should migrate it to use the same infrastructure as all
	// other tests (pkg/storage/etcd/testing).
	config.Etcd.StorageConfig.Type = "etcd2"
	_, ipnet, err := net.ParseCIDR(clusterIPRange)
	if err != nil {
		return err
	}
	config.ServiceClusterIPRange = *ipnet
	config.AllowPrivileged = true
	errCh := make(chan error)
	go func() {
		defer close(errCh)
		err := apiserver.Run(config)
		if err != nil {
			errCh <- fmt.Errorf("run apiserver error: %v", err)
		}
	}()

	err = readinessCheck("apiserver", []string{apiserverHealthCheckURL}, errCh)
	if err != nil {
		return err
	}
	return nil
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:29,代碼來源:apiserver.go

示例4: NewKubeAPIServer

// NewKubeAPIServer creates a new hyperkube Server object that includes the
// description and flags.
func NewKubeAPIServer() *Server {
	s := options.NewAPIServer()

	hks := Server{
		SimpleUsage: hyperkube.CommandApiserver,
		Long:        "The main API entrypoint and interface to the storage system.  The API server is also the focal point for all authorization decisions.",
		Run: func(_ *Server, _ []string) error {
			return app.Run(s)
		},
	}
	s.AddFlags(hks.Flags())
	return &hks
}
開發者ID:CodeJuan,項目名稱:kubernetes,代碼行數:15,代碼來源:kube-apiserver.go

示例5: Run

func (b *bootkube) Run() error {
	errch := make(chan error)
	go func() { errch <- apiapp.Run(b.apiServer) }()
	go func() { errch <- cmapp.Run(b.controller) }()
	go func() { errch <- schedapp.Run(b.scheduler) }()
	go func() {
		if err := CreateAssets(filepath.Join(b.assetDir, asset.AssetPathManifests), assetTimeout); err != nil {
			errch <- err
		}
	}()
	go func() { errch <- WaitUntilPodsRunning(requiredPods, assetTimeout) }()

	// If any of the bootkube services exit, it means it is unrecoverable and we should exit.
	return <-errch
}
開發者ID:40a,項目名稱:bootkube,代碼行數:15,代碼來源:bootkube.go

示例6: main

func main() {
	rand.Seed(time.Now().UTC().UnixNano())

	s := options.NewAPIServer()
	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)
	}
}
開發者ID:astropuffin,項目名稱:kubernetes,代碼行數:17,代碼來源:apiserver.go

示例7: Start

// Start starts the apiserver, returns when apiserver is ready.
func (a *APIServer) Start() error {
	config := options.NewAPIServer()
	config.StorageConfig.ServerList = []string{getEtcdClientURL()}
	_, ipnet, err := net.ParseCIDR(clusterIPRange)
	if err != nil {
		return err
	}
	config.ServiceClusterIPRange = *ipnet
	config.AllowPrivileged = true
	errCh := make(chan error)
	go func() {
		defer close(errCh)
		err := apiserver.Run(config)
		if err != nil {
			errCh <- fmt.Errorf("run apiserver error: %v", err)
		}
	}()

	err = readinessCheck([]string{apiserverHealthCheckURL}, errCh)
	if err != nil {
		return err
	}
	return nil
}
開發者ID:cheld,項目名稱:kubernetes,代碼行數:25,代碼來源:apiserver.go


注:本文中的k8s/io/kubernetes/cmd/kube-apiserver/app.Run函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。