Skip to content

Commit

Permalink
Add env var to override introspection bind address
Browse files Browse the repository at this point in the history
2b08772 (inadvertently?) changed the
bind address from `:61678` to `localhost:61678` which is backwards
incompatible and for those actually scraping the metrics via prometheus
makes the metrics endpoint entirely unusable (since prometheus isn't
local to each node in the cluster).

This path simply adds an env var to override the bind address.
  • Loading branch information
jacksontj committed Jun 5, 2019
1 parent dd63110 commit bcc21ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
17 changes: 13 additions & 4 deletions ipamd/introspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -55,7 +58,6 @@ func (c *IPAMContext) ServeIntrospection() {
return
}

log.Info("Serving introspection endpoints on ", introspectionAddress)
server := c.setupIntrospectionServer()
for {
once := sync.Once{}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bcc21ae

Please sign in to comment.