mirror of https://github.com/k3s-io/k3s
kube-scheduler make use of generic apiserver profiling
parent
c51fc2986b
commit
385a61e04f
|
@ -23,7 +23,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
|
@ -38,6 +37,8 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
|
"k8s.io/apiserver/pkg/server/mux"
|
||||||
|
"k8s.io/apiserver/pkg/server/routes"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||||
|
@ -470,17 +471,14 @@ func makeLeaderElectionConfig(config componentconfig.KubeSchedulerLeaderElection
|
||||||
// embed the metrics handler if the healthz and metrics address configurations
|
// embed the metrics handler if the healthz and metrics address configurations
|
||||||
// are the same.
|
// are the same.
|
||||||
func makeHealthzServer(config *componentconfig.KubeSchedulerConfiguration) *http.Server {
|
func makeHealthzServer(config *componentconfig.KubeSchedulerConfiguration) *http.Server {
|
||||||
mux := http.NewServeMux()
|
mux := mux.NewPathRecorderMux("kube-scheduler")
|
||||||
healthz.InstallHandler(mux)
|
healthz.InstallHandler(mux)
|
||||||
if config.HealthzBindAddress == config.MetricsBindAddress {
|
if config.HealthzBindAddress == config.MetricsBindAddress {
|
||||||
configz.InstallHandler(mux)
|
configz.InstallHandler(mux)
|
||||||
mux.Handle("/metrics", prometheus.Handler())
|
mux.Handle("/metrics", prometheus.Handler())
|
||||||
}
|
}
|
||||||
if config.EnableProfiling {
|
if config.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 config.EnableContentionProfiling {
|
if config.EnableContentionProfiling {
|
||||||
goruntime.SetBlockProfileRate(1)
|
goruntime.SetBlockProfileRate(1)
|
||||||
}
|
}
|
||||||
|
@ -493,14 +491,11 @@ func makeHealthzServer(config *componentconfig.KubeSchedulerConfiguration) *http
|
||||||
|
|
||||||
// makeMetricsServer builds a metrics server from the config.
|
// makeMetricsServer builds a metrics server from the config.
|
||||||
func makeMetricsServer(config *componentconfig.KubeSchedulerConfiguration) *http.Server {
|
func makeMetricsServer(config *componentconfig.KubeSchedulerConfiguration) *http.Server {
|
||||||
mux := http.NewServeMux()
|
mux := mux.NewPathRecorderMux("kube-scheduler")
|
||||||
configz.InstallHandler(mux)
|
configz.InstallHandler(mux)
|
||||||
mux.Handle("/metrics", prometheus.Handler())
|
mux.Handle("/metrics", prometheus.Handler())
|
||||||
if config.EnableProfiling {
|
if config.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 config.EnableContentionProfiling {
|
if config.EnableContentionProfiling {
|
||||||
goruntime.SetBlockProfileRate(1)
|
goruntime.SetBlockProfileRate(1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue