mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Add a flag allowing contention profiling of the API server
This commit is contained in:
parent
984fb7112a
commit
c97633b1f5
@ -106,6 +106,7 @@ container-port
|
|||||||
container-runtime
|
container-runtime
|
||||||
container-runtime-endpoint
|
container-runtime-endpoint
|
||||||
contain-pod-resources
|
contain-pod-resources
|
||||||
|
contention-profiling
|
||||||
controller-start-interval
|
controller-start-interval
|
||||||
cors-allowed-origins
|
cors-allowed-origins
|
||||||
cpu-cfs-quota
|
cpu-cfs-quota
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
goruntime "runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -80,6 +81,8 @@ type Config struct {
|
|||||||
// allow downstream consumers to disable the index route
|
// allow downstream consumers to disable the index route
|
||||||
EnableIndex bool
|
EnableIndex bool
|
||||||
EnableProfiling bool
|
EnableProfiling bool
|
||||||
|
// Requires generic profiling enabled
|
||||||
|
EnableContentionProfiling bool
|
||||||
EnableMetrics bool
|
EnableMetrics bool
|
||||||
EnableGarbageCollection bool
|
EnableGarbageCollection bool
|
||||||
|
|
||||||
@ -285,6 +288,7 @@ func (c *Config) ApplyOptions(options *options.ServerRunOptions) *Config {
|
|||||||
c.CorsAllowedOriginList = options.CorsAllowedOriginList
|
c.CorsAllowedOriginList = options.CorsAllowedOriginList
|
||||||
c.EnableGarbageCollection = options.EnableGarbageCollection
|
c.EnableGarbageCollection = options.EnableGarbageCollection
|
||||||
c.EnableProfiling = options.EnableProfiling
|
c.EnableProfiling = options.EnableProfiling
|
||||||
|
c.EnableContentionProfiling = options.EnableContentionProfiling
|
||||||
c.EnableSwaggerUI = options.EnableSwaggerUI
|
c.EnableSwaggerUI = options.EnableSwaggerUI
|
||||||
c.ExternalAddress = options.ExternalHost
|
c.ExternalAddress = options.ExternalHost
|
||||||
c.MaxRequestsInFlight = options.MaxRequestsInFlight
|
c.MaxRequestsInFlight = options.MaxRequestsInFlight
|
||||||
@ -462,6 +466,9 @@ func (s *GenericAPIServer) installAPI(c *Config) {
|
|||||||
}
|
}
|
||||||
if c.EnableProfiling {
|
if c.EnableProfiling {
|
||||||
routes.Profiling{}.Install(s.HandlerContainer)
|
routes.Profiling{}.Install(s.HandlerContainer)
|
||||||
|
if c.EnableContentionProfiling {
|
||||||
|
goruntime.SetBlockProfileRate(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if c.EnableMetrics {
|
if c.EnableMetrics {
|
||||||
if c.EnableProfiling {
|
if c.EnableProfiling {
|
||||||
|
@ -83,6 +83,7 @@ type ServerRunOptions struct {
|
|||||||
AuditLogMaxSize int
|
AuditLogMaxSize int
|
||||||
EnableGarbageCollection bool
|
EnableGarbageCollection bool
|
||||||
EnableProfiling bool
|
EnableProfiling bool
|
||||||
|
EnableContentionProfiling bool
|
||||||
EnableSwaggerUI bool
|
EnableSwaggerUI bool
|
||||||
EnableWatchCache bool
|
EnableWatchCache bool
|
||||||
EtcdServersOverrides []string
|
EtcdServersOverrides []string
|
||||||
@ -139,6 +140,7 @@ func NewServerRunOptions() *ServerRunOptions {
|
|||||||
DeleteCollectionWorkers: 1,
|
DeleteCollectionWorkers: 1,
|
||||||
EnableGarbageCollection: true,
|
EnableGarbageCollection: true,
|
||||||
EnableProfiling: true,
|
EnableProfiling: true,
|
||||||
|
EnableContentionProfiling: false,
|
||||||
EnableWatchCache: true,
|
EnableWatchCache: true,
|
||||||
InsecureBindAddress: net.ParseIP("127.0.0.1"),
|
InsecureBindAddress: net.ParseIP("127.0.0.1"),
|
||||||
InsecurePort: 8080,
|
InsecurePort: 8080,
|
||||||
@ -347,6 +349,8 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
|
|||||||
|
|
||||||
fs.BoolVar(&s.EnableProfiling, "profiling", s.EnableProfiling,
|
fs.BoolVar(&s.EnableProfiling, "profiling", s.EnableProfiling,
|
||||||
"Enable profiling via web interface host:port/debug/pprof/")
|
"Enable profiling via web interface host:port/debug/pprof/")
|
||||||
|
fs.BoolVar(&s.EnableContentionProfiling, "contention-profiling", s.EnableContentionProfiling,
|
||||||
|
"Enable contention profiling. Requires --profiling to be set to work.")
|
||||||
|
|
||||||
fs.BoolVar(&s.EnableSwaggerUI, "enable-swagger-ui", s.EnableSwaggerUI,
|
fs.BoolVar(&s.EnableSwaggerUI, "enable-swagger-ui", s.EnableSwaggerUI,
|
||||||
"Enables swagger ui on the apiserver at /swagger-ui")
|
"Enables swagger ui on the apiserver at /swagger-ui")
|
||||||
|
Loading…
Reference in New Issue
Block a user