Skip to content

Commit

Permalink
Enable profiler-address to be configured (kubernetes#9311)
Browse files Browse the repository at this point in the history
Signed-off-by: aimuz <[email protected]>

Signed-off-by: aimuz <[email protected]>
  • Loading branch information
aimuz authored Dec 4, 2022
1 parent 49bd5dd commit 15c4078
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/dataplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ func main() {
mc.Start(conf.ValidationWebhook)

if conf.EnableProfiling {
// TODO: Turn Profiler address configurable via flags
go metrics.RegisterProfiler("127.0.0.1", nginx.ProfilerPort)
go metrics.RegisterProfiler(nginx.ProfilerAddress, nginx.ProfilerPort)
}

ngx := controller.NewNGINXController(conf, mc)
Expand Down
2 changes: 1 addition & 1 deletion cmd/nginx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func main() {
mc.Start(conf.ValidationWebhook)

if conf.EnableProfiling {
go metrics.RegisterProfiler("127.0.0.1", nginx.ProfilerPort)
go metrics.RegisterProfiler(nginx.ProfilerAddress, nginx.ProfilerPort)
}

ngx := controller.NewNGINXController(conf, mc)
Expand Down
3 changes: 3 additions & 0 deletions internal/nginx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import (
// ProfilerPort port used by the ingress controller to expose the Go Profiler when it is enabled.
var ProfilerPort = 10245

// ProfilerAddress IP address used by the ingress controller to expose the Go Profiler when it is enabled.
var ProfilerAddress = "127.0.0.1"

// TemplatePath path of the NGINX template
var TemplatePath = "/etc/nginx/template/nginx.tmpl"

Expand Down
5 changes: 4 additions & 1 deletion pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package flags
import (
"flag"
"fmt"
"net"
"os"
"time"

Expand Down Expand Up @@ -201,7 +202,8 @@ Takes the form "<host>:port". If not provided, no admission controller is starte

internalLoggerAddress = flags.String("internal-logger-address", "127.0.0.1:11514", "Address to be used when binding internal syslogger")

profilerPort = flags.Int("profiler-port", 10245, "Port to use for expose the ingress controller Go profiler when it is enabled.")
profilerPort = flags.Int("profiler-port", 10245, "Port to use for expose the ingress controller Go profiler when it is enabled.")
profilerAddress = flags.IP("profiler-address", net.ParseIP("127.0.0.1"), "IP address used by the ingress controller to expose the Go Profiler when it is enabled.")

statusUpdateInterval = flags.Int("status-update-interval", status.UpdateInterval, "Time interval in seconds in which the status should check if an update is required. Default is 60 seconds")

Expand Down Expand Up @@ -275,6 +277,7 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
nginx.StatusPort = *statusPort
nginx.StreamPort = *streamPort
nginx.ProfilerPort = *profilerPort
nginx.ProfilerAddress = profilerAddress.String()

if *enableSSLPassthrough && !ing_net.IsPortAvailable(*sslProxyPort) {
return false, nil, fmt.Errorf("port %v is already in use. Please check the flag --ssl-passthrough-proxy-port", *sslProxyPort)
Expand Down

0 comments on commit 15c4078

Please sign in to comment.