mirror of https://github.com/k3s-io/k3s
controller-manager make use of generic apiserver profiling
parent
f331434774
commit
c51fc2986b
|
@ -18,7 +18,6 @@ package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
|
||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -28,6 +27,8 @@ import (
|
||||||
apirequest "k8s.io/apiserver/pkg/endpoints/request"
|
apirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
genericfilters "k8s.io/apiserver/pkg/server/filters"
|
genericfilters "k8s.io/apiserver/pkg/server/filters"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
|
"k8s.io/apiserver/pkg/server/mux"
|
||||||
|
"k8s.io/apiserver/pkg/server/routes"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/util/configz"
|
"k8s.io/kubernetes/pkg/util/configz"
|
||||||
)
|
)
|
||||||
|
@ -37,13 +38,10 @@ type serveFunc func(handler http.Handler, shutdownTimeout time.Duration, stopCh
|
||||||
// Serve creates a base handler chain for a controller manager. It runs the
|
// Serve creates a base handler chain for a controller manager. It runs the
|
||||||
// the chain with the given serveFunc.
|
// the chain with the given serveFunc.
|
||||||
func Serve(c *CompletedConfig, serveFunc serveFunc, stopCh <-chan struct{}) error {
|
func Serve(c *CompletedConfig, serveFunc serveFunc, stopCh <-chan struct{}) error {
|
||||||
mux := http.NewServeMux()
|
mux := mux.NewPathRecorderMux("controller-manager")
|
||||||
healthz.InstallHandler(mux)
|
healthz.InstallHandler(mux)
|
||||||
if c.ComponentConfig.EnableProfiling {
|
if c.ComponentConfig.EnableProfiling {
|
||||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
routes.Profiling{}.Install(mux)
|
||||||
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
|
||||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
|
||||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
|
||||||
if c.ComponentConfig.EnableContentionProfiling {
|
if c.ComponentConfig.EnableContentionProfiling {
|
||||||
goruntime.SetBlockProfileRate(1)
|
goruntime.SetBlockProfileRate(1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue