diff --git a/README.md b/README.md index eab6117b25..f09462cb6b 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,11 @@ Default: Unset Valid Values: `stdout` or a file path Specifies where to write the logging output. Either to stdout or to override the default file. +`INTROSPECTION_BIND_ADDRESS` +Type: String +Default: `127.0.0.1:61679` +Specifies the bind address for the introspection endpoint. + `DISABLE_INTROSPECTION` Type: Boolean Default: `false` diff --git a/ipamd/introspect.go b/ipamd/introspect.go index 34d2d116bf..90be14e134 100644 --- a/ipamd/introspect.go +++ b/ipamd/introspect.go @@ -27,8 +27,11 @@ import ( ) const ( - // introspectionAddress is listening on localhost 61679 for ipamd introspection - introspectionAddress = "127.0.0.1:61679" + // defaultIntrospectionAddress is listening on localhost 61679 for ipamd introspection + defaultIntrospectionBindAddress = "127.0.0.1:61679" + + // Environment variable to define the bind address for the introspection endpoint + introspectionBindAddress = "INTROSPECTION_BIND_ADDRESS" // Environment variable to disable the introspection endpoints envDisableIntrospection = "DISABLE_INTROSPECTION" @@ -55,7 +58,6 @@ func (c *IPAMContext) ServeIntrospection() { return } - log.Info("Serving introspection endpoints on ", introspectionAddress) server := c.setupIntrospectionServer() for { once := sync.Once{} @@ -102,8 +104,15 @@ func (c *IPAMContext) setupIntrospectionServer() *http.Server { loggingServeMux := http.NewServeMux() loggingServeMux.Handle("/", LoggingHandler{serveMux}) + addr, ok := os.LookupEnv(introspectionBindAddress) + if !ok { + addr = defaultIntrospectionBindAddress + } + + log.Info("Serving introspection endpoints on ", addr) + server := &http.Server{ - Addr: introspectionAddress, + Addr: addr, Handler: loggingServeMux, ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second,