Enable profiler-address to be configured (#9311)

Signed-off-by: aimuz <mr.imuz@gmail.com>

Signed-off-by: aimuz <mr.imuz@gmail.com>
This commit is contained in:
aimuz 2022-12-05 03:49:54 +08:00 committed by GitHub
parent 49bd5dd763
commit 15c4078032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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"

View file

@ -19,6 +19,7 @@ package flags
import (
"flag"
"fmt"
"net"
"os"
"time"
@ -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")
@ -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)