Skip to content

Commit

Permalink
Added pprof config
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <vladislav.byrgazov@xored.com>
  • Loading branch information
Vladislav Byrgazov committed Aug 15, 2024
1 parent 430a0f1 commit 25cec78
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ docker build .
* `NSM_SIDECAR_REQUESTS_MEMORY` - Lower bound of the NSM sidecar requests memory limits (in k8s resource management units) (default: "40Mi")
* `NSM_SIDECAR_REQUESTS_CPU` - Lower bound of the NSM sidecar requests CPU limits (in k8s resource management units) (default: "100m")
* `NSM_KUBELET_QPS` - kubelet QPS config (default: "50")
* `NSM_PPROF_ENABLED` - is pprof enabled (default: "false")
* `NSM_PPROF_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060")

# Testing

Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type Config struct {
SidecarLimitsCPU string `default:"200m" desc:"Lower bound of the NSM sidecar CPU limit (in k8s resource management units)" split_words:"true"`
SidecarRequestsMemory string `default:"40Mi" desc:"Lower bound of the NSM sidecar requests memory limits (in k8s resource management units)" split_words:"true"`
SidecarRequestsCPU string `default:"100m" desc:"Lower bound of the NSM sidecar requests CPU limits (in k8s resource management units)" split_words:"true"`
PprofEnabled bool `default:"false" desc:"is pprof enabled" split_words:"true"`
PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"`
// QPS for 50 NSC
KubeletQPS int `default:"50" desc:"kubelet QPS config" split_words:"true"`
envs []corev1.EnvVar
Expand Down
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
_ "github.com/networkservicemesh/sdk-k8s/pkg/tools/k8s"
_ "github.com/networkservicemesh/sdk/pkg/tools/nsurl"
_ "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
_ "github.com/networkservicemesh/sdk/pkg/tools/pprofutils"
_ "github.com/pkg/errors"
_ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
_ "github.com/spiffe/go-spiffe/v2/workloadapi"
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
kubeutils "github.com/networkservicemesh/sdk-k8s/pkg/tools/k8s"
"github.com/networkservicemesh/sdk/pkg/tools/nsurl"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
"github.com/networkservicemesh/sdk/pkg/tools/pprofutils"
)

var deserializer = serializer.NewCodecFactory(runtime.NewScheme()).UniversalDeserializer()
Expand Down Expand Up @@ -438,6 +439,11 @@ func main() {
}()
}

// Configure pprof
if conf.PprofEnabled {
go pprofutils.ListenAndServe(ctx, conf.PprofListenOn)
}

if conf.WebhookMode == config.SelfregisterMode {
unregister := registerSelf(ctx, conf, logger)
defer func() {
Expand Down

0 comments on commit 25cec78

Please sign in to comment.