From 21cc7bd6d55f18f0168432226a47782b1c152a80 Mon Sep 17 00:00:00 2001 From: Anton Stuchinskii Date: Wed, 12 Jul 2023 17:23:30 +0200 Subject: [PATCH] Added pprof endpoint --- apis/config/v1beta1/configuration_types.go | 8 ++++++++ charts/kueue/values.yaml | 1 + config/components/manager/controller_manager_config.yaml | 1 + pkg/config/config.go | 4 ++++ pkg/config/config_test.go | 2 ++ 5 files changed, 16 insertions(+) diff --git a/apis/config/v1beta1/configuration_types.go b/apis/config/v1beta1/configuration_types.go index b398b91b49..fb2d023210 100644 --- a/apis/config/v1beta1/configuration_types.go +++ b/apis/config/v1beta1/configuration_types.go @@ -82,6 +82,14 @@ type ControllerManager struct { // +optional Health ControllerHealth `json:"health,omitempty"` + // PprofBindAddress is the TCP address that the controller should bind to + // for serving pprof. + // It can be set to "" or "0" to disable the pprof serving. + // Since pprof may contain sensitive information, make sure to protect it + // before exposing it to public. + // +optional + PprofBindAddress string `json:"pprofBindAddress,omitempty"` + // Controller contains global configuration options for controllers // registered within this manager. // +optional diff --git a/charts/kueue/values.yaml b/charts/kueue/values.yaml index 48731518c4..6882afe592 100644 --- a/charts/kueue/values.yaml +++ b/charts/kueue/values.yaml @@ -61,6 +61,7 @@ managerConfig: clientConnection: qps: 50 burst: 100 + #pprofBindAddress: :8082 #waitForPodsReady: # enable: true #manageJobsWithoutQueueName: true diff --git a/config/components/manager/controller_manager_config.yaml b/config/components/manager/controller_manager_config.yaml index 6075370c8d..6d99cbef01 100644 --- a/config/components/manager/controller_manager_config.yaml +++ b/config/components/manager/controller_manager_config.yaml @@ -19,6 +19,7 @@ controller: clientConnection: qps: 50 burst: 100 +#pprofBindAddress: :8082 #waitForPodsReady: # enable: true #manageJobsWithoutQueueName: true diff --git a/pkg/config/config.go b/pkg/config/config.go index 6aada3dd15..c8d9f7b51e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -52,6 +52,10 @@ func addTo(o *ctrl.Options, cfg *configapi.Configuration) { o.MetricsBindAddress = cfg.Metrics.BindAddress } + if o.PprofBindAddress == "" && cfg.PprofBindAddress != "" { + o.PprofBindAddress = cfg.PprofBindAddress + } + if o.HealthProbeBindAddress == "" && cfg.Health.HealthProbeBindAddress != "" { o.HealthProbeBindAddress = cfg.Health.HealthProbeBindAddress } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 931d31f541..8d804c8b51 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -189,6 +189,7 @@ health: livenessEndpointName: live metrics: bindAddress: :8080 +pprofBindAddress: :8082 leaderElection: leaderElect: true resourceName: c1f6bfd2.kueue.x-k8s.io @@ -474,6 +475,7 @@ integrations: ReadinessEndpointName: "ready", LivenessEndpointName: "live", MetricsBindAddress: configapi.DefaultMetricsBindAddress, + PprofBindAddress: ":8082", LeaderElection: true, LeaderElectionID: configapi.DefaultLeaderElectionID, LeaderElectionNamespace: "namespace",