Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env var to override introspection bind address #501

Merged
merged 1 commit into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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