Consul TCP Checks Should Default to Bind Addr
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
Looking at the documentation for service configs, this part has me a bit confused:
For a service definition:
> The address field can be used to specify a service-specific IP address. __By default, the IP address of the agent is used, and this does not need to be provided__. The port field can be used as well to make a service-oriented architecture simpler to configure; this way, the address and port of a service can be discovered.
And for a TCP health check definition:
> TCP + Interval - These checks make an TCP connection attempt every Interval (e.g. every 30 seconds) to the specified IP/hostname and port. __If no hostname is specified, it defaults to "localhost"__.
It seems to me that the service's bind address should be honored as the default for all child healthcheck definitions for that service, instead of switching over to `localhost`. Otherwise, in the current scenario, there is no way to set up a TCP healthcheck for a service that listens __only__ on the bind address without knowing the node's external IP in the first place.
This suggestion may be a backwards incompatible change, but it seems to be more in line with the service-to-health-check relationship.
If this is not an option, then a workaround like `GetInteraceIP` should perhaps be made available in the healthcheck definition as it is through command-line arguments so users can dynamically specify the target IP to a non-loopback address. Making envvars available to be injected similarly might also work, and be more flexible.
Contributor guide
Assessment
This issue has not been assessed yet.