当前位置: 首页>>代码示例>>Golang>>正文


Golang healthz.InstallHandler函数代码示例

本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/healthz.InstallHandler函数的典型用法代码示例。如果您正苦于以下问题:Golang InstallHandler函数的具体用法?Golang InstallHandler怎么用?Golang InstallHandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了InstallHandler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: InstallDefaultHandlers

// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
func (s *Server) InstallDefaultHandlers() {
	healthz.InstallHandler(s.mux)
	s.mux.HandleFunc("/podInfo", s.handlePodInfo)
	s.mux.HandleFunc("/boundPods", s.handleBoundPods)
	s.mux.HandleFunc("/stats/", s.handleStats)
	s.mux.HandleFunc("/spec/", s.handleSpec)
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:8,代码来源:server.go

示例2: InstallSupport

// InstallSupport registers the APIServer support functions into a mux.
func InstallSupport(mux mux) {
	healthz.InstallHandler(mux)
	mux.Handle("/logs/", http.StripPrefix("/logs/", http.FileServer(http.Dir("/var/log/"))))
	mux.Handle("/proxy/minion/", http.StripPrefix("/proxy/minion", http.HandlerFunc(handleProxyMinion)))
	mux.HandleFunc("/version", handleVersion)
	mux.HandleFunc("/", handleIndex)
}
开发者ID:hungld,项目名称:kubernetes,代码行数:8,代码来源:apiserver.go

示例3: New

// New creates a new APIServer object.
// 'storage' contains a map of handlers.
// 'prefix' is the hosting path prefix.
func New(storage map[string]RESTStorage, prefix string) *APIServer {
	s := &APIServer{
		storage: storage,
		prefix:  strings.TrimRight(prefix, "/"),
		ops:     NewOperations(),
		mux:     http.NewServeMux(),
		// Delay just long enough to handle most simple write operations
		asyncOpWait: time.Millisecond * 25,
	}

	// Primary API methods
	s.mux.HandleFunc(s.prefix+"/", s.handleREST)
	s.mux.HandleFunc(s.watchPrefix()+"/", s.handleWatch)

	// Support services for the apiserver
	s.mux.Handle("/logs/", http.StripPrefix("/logs/", http.FileServer(http.Dir("/var/log/"))))
	healthz.InstallHandler(s.mux)
	s.mux.HandleFunc("/version", handleVersion)
	s.mux.HandleFunc("/", handleIndex)

	// Handle both operations and operations/* with the same handler
	s.mux.HandleFunc(s.operationPrefix(), s.handleOperation)
	s.mux.HandleFunc(s.operationPrefix()+"/", s.handleOperation)

	// Proxy minion requests
	s.mux.Handle("/proxy/minion/", http.StripPrefix("/proxy/minion", http.HandlerFunc(handleProxyMinion)))

	return s
}
开发者ID:kleopatra999,项目名称:kubernetes,代码行数:32,代码来源:apiserver.go

示例4: Start

func Start(config *Config) error {
	if err := clone(config); err != nil {
		return err
	}
	handler := handler(config)

	ops := http.NewServeMux()
	if config.AllowHooks {
		ops.Handle("/hooks/", prometheus.InstrumentHandler("hooks", http.StripPrefix("/hooks", hooksHandler(config))))
	}
	/*ops.Handle("/reflect/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		defer r.Body.Close()
		fmt.Fprintf(os.Stdout, "%s %s\n", r.Method, r.URL)
		io.Copy(os.Stdout, r.Body)
	}))*/
	ops.Handle("/metrics", prometheus.UninstrumentedHandler())
	healthz.InstallHandler(ops)

	mux := http.NewServeMux()
	mux.Handle("/", prometheus.InstrumentHandler("git", handler))
	mux.Handle("/_/", http.StripPrefix("/_", ops))

	log.Printf("Serving %s on %s", config.Home, config.Listen)
	return http.ListenAndServe(config.Listen, mux)
}
开发者ID:cjnygard,项目名称:origin,代码行数:25,代码来源:gitserver.go

示例5: Run

// Run runs the specified SchedulerServer.  This should never exit.
func (s *SchedulerServer) Run(_ []string) error {
	if s.Kubeconfig == "" && s.Master == "" {
		glog.Warningf("Neither --kubeconfig nor --master was specified.  Using default API client.  This might not work.")
	}

	// This creates a client, first loading any specified kubeconfig
	// file, and then overriding the Master flag, if non-empty.
	kubeconfig, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
		&clientcmd.ClientConfigLoadingRules{ExplicitPath: s.Kubeconfig},
		&clientcmd.ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: s.Master}}).ClientConfig()
	if err != nil {
		return err
	}
	kubeconfig.QPS = 20.0
	kubeconfig.Burst = 30

	kubeClient, err := client.New(kubeconfig)
	if err != nil {
		glog.Fatalf("Invalid API configuration: %v", err)
	}

	go func() {
		mux := http.NewServeMux()
		healthz.InstallHandler(mux)
		if s.EnableProfiling {
			mux.HandleFunc("/debug/pprof/", pprof.Index)
			mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
			mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
		}
		mux.Handle("/metrics", prometheus.Handler())

		server := &http.Server{
			Addr:    net.JoinHostPort(s.Address.String(), strconv.Itoa(s.Port)),
			Handler: mux,
		}
		glog.Fatal(server.ListenAndServe())
	}()

	configFactory := factory.NewConfigFactory(kubeClient)
	config, err := s.createConfig(configFactory)
	if err != nil {
		glog.Fatalf("Failed to create scheduler configuration: %v", err)
	}

	config.Cloud, err = cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
	if err != nil {
		glog.Fatalf("Cloud provider could not be initialized: %v", err)
	}

	eventBroadcaster := record.NewBroadcaster()
	config.Recorder = eventBroadcaster.NewRecorder(api.EventSource{Component: "scheduler"})
	eventBroadcaster.StartLogging(glog.Infof)
	eventBroadcaster.StartRecordingToSink(kubeClient.Events(""))

	sched := scheduler.New(config)
	sched.Run()

	select {}
}
开发者ID:ravigadde,项目名称:kube-scheduler,代码行数:60,代码来源:server.go

示例6: InstallDefaultHandlers

// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
func (s *Server) InstallDefaultHandlers() {
	healthz.InstallHandler(s.mux,
		healthz.PingHealthz,
		healthz.NamedCheck("docker", s.dockerHealthCheck),
		healthz.NamedCheck("hostname", s.hostnameHealthCheck),
	)
	s.mux.HandleFunc("/pods", s.handlePods)
	s.mux.HandleFunc("/stats/", s.handleStats)
	s.mux.HandleFunc("/spec/", s.handleSpec)
}
开发者ID:cjnygard,项目名称:origin,代码行数:11,代码来源:server.go

示例7: InstallDefaultHandlers

// InstallDefaultHandlers registers the set of supported HTTP request patterns with the mux.
func (s *Server) InstallDefaultHandlers() {
	healthz.InstallHandler(s.mux)
	s.mux.HandleFunc("/container", s.handleContainer)
	s.mux.HandleFunc("/containers", s.handleContainers)
	s.mux.HandleFunc("/podInfo", s.handlePodInfo)
	s.mux.HandleFunc("/stats/", s.handleStats)
	s.mux.HandleFunc("/logs/", s.handleLogs)
	s.mux.HandleFunc("/spec/", s.handleSpec)
	s.mux.HandleFunc("/run/", s.handleRun)
}
开发者ID:hungld,项目名称:kubernetes,代码行数:11,代码来源:server.go

示例8: InstallDefaultHandlers

// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
func (s *Server) InstallDefaultHandlers() {
	healthz.InstallHandler(s.mux)
	s.mux.HandleFunc("/podInfo", s.handlePodInfo)
	s.mux.HandleFunc("/boundPods", s.handleBoundPods)
	s.mux.HandleFunc("/stats/", s.handleStats)
	s.mux.HandleFunc("/spec/", s.handleSpec)
	s.mux.HandleFunc("/podOp", s.handlePodOp)
	s.mux.HandleFunc("/image/", s.handleImage)
	s.mux.HandleFunc("/podUpgrade/", s.handlePodUpgrade)
	s.mux.HandleFunc("/podCgroup", s.handlePodCgroup)
}
开发者ID:TencentSA,项目名称:kubernetes-0.5,代码行数:12,代码来源:server.go

示例9: InstallSupport

// TODO: document all handlers
// InstallSupport registers the APIServer support functions
func InstallSupport(container *restful.Container, ws *restful.WebService) {
	// TODO: convert healthz to restful and remove container arg
	healthz.InstallHandler(container.ServeMux)

	// Set up a service to return the git code version.
	ws.Path("/version")
	ws.Doc("git code version from which this is built")
	ws.Route(
		ws.GET("/").To(handleVersion).
			Doc("get the code version").
			Operation("getCodeVersion").
			Produces(restful.MIME_JSON).
			Consumes(restful.MIME_JSON))
}
开发者ID:nhr,项目名称:kubernetes,代码行数:16,代码来源:apiserver.go

示例10: ListenAndServeKubeletReadOnlyServer

// ListenAndServeKubeletReadOnlyServer initializes a server to respond to HTTP network requests on the Kubelet.
func ListenAndServeKubeletReadOnlyServer(host HostInterface, address net.IP, port uint) {
	glog.V(1).Infof("Starting to listen read-only on %s:%d", address, port)
	s := &Server{host, http.NewServeMux()}
	healthz.InstallHandler(s.mux)
	s.mux.HandleFunc("/stats/", s.handleStats)
	s.mux.Handle("/metrics", prometheus.Handler())

	server := &http.Server{
		Addr:           net.JoinHostPort(address.String(), strconv.FormatUint(uint64(port), 10)),
		Handler:        s,
		ReadTimeout:    5 * time.Minute,
		WriteTimeout:   5 * time.Minute,
		MaxHeaderBytes: 1 << 20,
	}
	glog.Fatal(server.ListenAndServe())
}
开发者ID:cjnygard,项目名称:origin,代码行数:17,代码来源:server.go

示例11: InstallSupport

// TODO: document all handlers
// InstallSupport registers the APIServer support functions
func InstallSupport(mux Mux, ws *restful.WebService, enableResettingMetrics bool) {
	// TODO: convert healthz and metrics to restful and remove container arg
	healthz.InstallHandler(mux)
	mux.Handle("/metrics", prometheus.Handler())
	if enableResettingMetrics {
		mux.HandleFunc("/resetMetrics", metrics.Reset)
	}

	// Set up a service to return the git code version.
	ws.Path("/version")
	ws.Doc("git code version from which this is built")
	ws.Route(
		ws.GET("/").To(handleVersion).
			Doc("get the code version").
			Operation("getCodeVersion").
			Produces(restful.MIME_JSON).
			Consumes(restful.MIME_JSON))
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:20,代码来源:apiserver.go

示例12: New

// New creates a new APIServer object. 'storage' contains a map of handlers. 'codec'
// is an interface for decoding to and from JSON. 'prefix' is the hosting path prefix.
//
// The codec will be used to decode the request body into an object pointer returned by
// RESTStorage.New().  The Create() and Update() methods should cast their argument to
// the type returned by New().
// TODO: add multitype codec serialization
func New(storage map[string]RESTStorage, codec Codec, prefix string) *APIServer {
	s := &APIServer{
		storage: storage,
		codec:   codec,
		ops:     NewOperations(),
		// Delay just long enough to handle most simple write operations
		asyncOpWait: time.Millisecond * 25,
	}

	mux := http.NewServeMux()

	prefix = strings.TrimRight(prefix, "/")

	// Primary API handlers
	restPrefix := prefix + "/"
	mux.Handle(restPrefix, http.StripPrefix(restPrefix, http.HandlerFunc(s.handleREST)))

	// Watch API handlers
	watchPrefix := path.Join(prefix, "watch") + "/"
	mux.Handle(watchPrefix, http.StripPrefix(watchPrefix, &WatchHandler{storage, codec}))

	// Support services for the apiserver
	logsPrefix := "/logs/"
	mux.Handle(logsPrefix, http.StripPrefix(logsPrefix, http.FileServer(http.Dir("/var/log/"))))
	healthz.InstallHandler(mux)
	mux.HandleFunc("/version", handleVersion)
	mux.HandleFunc("/", handleIndex)

	// Handle both operations and operations/* with the same handler
	handler := &OperationHandler{s.ops, s.codec}
	operationPrefix := path.Join(prefix, "operations")
	mux.Handle(operationPrefix, http.StripPrefix(operationPrefix, handler))
	operationsPrefix := operationPrefix + "/"
	mux.Handle(operationsPrefix, http.StripPrefix(operationsPrefix, handler))

	// Proxy minion requests
	mux.Handle("/proxy/minion/", http.StripPrefix("/proxy/minion", http.HandlerFunc(handleProxyMinion)))

	s.handler = mux

	return s
}
开发者ID:kei-yamazaki,项目名称:kubernetes,代码行数:49,代码来源:apiserver.go

示例13: New

// New creates a new APIServer object.
// 'storage' contains a map of handlers.
// 'prefix' is the hosting path prefix.
func New(storage map[string]RESTStorage, prefix string) *APIServer {
	s := &APIServer{
		storage: storage,
		prefix:  strings.TrimRight(prefix, "/"),
		ops:     NewOperations(),
		mux:     http.NewServeMux(),
	}

	s.mux.Handle("/logs/", http.StripPrefix("/logs/", http.FileServer(http.Dir("/var/log/"))))
	s.mux.HandleFunc(s.prefix+"/", s.ServeREST)
	healthz.InstallHandler(s.mux)
	s.mux.HandleFunc("/index.html", s.handleIndex)

	// Handle both operations and operations/* with the same handler
	opPrefix := path.Join(s.prefix, "operations")
	s.mux.HandleFunc(opPrefix, s.handleOperationRequest)
	s.mux.HandleFunc(opPrefix+"/", s.handleOperationRequest)

	return s
}
开发者ID:ryfow,项目名称:kubernetes,代码行数:23,代码来源:apiserver.go

示例14: New

// New creates a new APIServer object.
// 'storage' contains a map of handlers.
// 'prefix' is the hosting path prefix.
func New(storage map[string]RESTStorage, prefix string) *APIServer {
	s := &APIServer{
		storage: storage,
		prefix:  strings.TrimRight(prefix, "/"),
		ops:     NewOperations(),
		mux:     http.NewServeMux(),
	}

	s.mux.Handle("/logs/", http.StripPrefix("/logs/", http.FileServer(http.Dir("/var/log/"))))
	s.mux.HandleFunc(s.prefix+"/", s.ServeREST)
	healthz.InstallHandler(s.mux)

	s.mux.HandleFunc("/", s.handleIndex)

	// Handle both operations and operations/* with the same handler
	s.mux.HandleFunc(s.operationPrefix(), s.handleOperationRequest)
	s.mux.HandleFunc(s.operationPrefix()+"/", s.handleOperationRequest)

	s.mux.HandleFunc(s.watchPrefix()+"/", s.handleWatch)

	s.mux.HandleFunc("/proxy/minion/", s.handleMinionReq)

	return s
}
开发者ID:ngpestelos,项目名称:kubernetes,代码行数:27,代码来源:apiserver.go

示例15: InstallSupport

// TODO: document all handlers
// InstallSupport registers the APIServer support functions
func InstallSupport(container *restful.Container, ws *restful.WebService) {
	// TODO: convert healthz to restful and remove container arg
	healthz.InstallHandler(container.ServeMux)
	ws.Route(ws.GET("/").To(handleIndex))
	ws.Route(ws.GET("/version").To(handleVersion))
}
开发者ID:TencentSA,项目名称:kubernetes-0.5,代码行数:8,代码来源:apiserver.go


注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/healthz.InstallHandler函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。