-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
advertise specific address for a service #570
advertise specific address for a service #570
Conversation
Enable setting a specific address in a service definition for advertise. If no specific address is given it will fallback to the node address and reassemble the old behaviour.
+1 This is fantastic functionality. |
Awesome! I was planning to tackle this for 0.5 but you beat me to it :) Reviewing now. |
@@ -625,7 +629,7 @@ func (d *DNSServer) serviceSRVRecords(dc string, nodes structs.CheckServiceNodes | |||
resp.Answer = append(resp.Answer, srvRec) | |||
|
|||
// Add the extra record | |||
records := d.formatNodeRecord(&node.Node, srvRec.Target, dns.TypeANY, ttl) | |||
records := d.formatNodeRecord(&node.Node, node.Node.Address, srvRec.Target, dns.TypeANY, ttl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the SRV also needs to handle the case of the override address
Overall looks really good! I think we need to add some more tests to the DNS stuff to test the behavior works there as expected, as well as for the changes in the state_store. |
I did add the SRV change. |
Awesome! |
Added some tests, and made a minor change to preserve API compatibility. |
The Address field was introduced in hashicorp#570. This patch extends this to the api.
The Address field was introduced in hashicorp#570. This patch extends this to the api.
* make sync-catalog work with clients disable Currently the sync-catalog won't work when the clients are disable because of the use of `HOST_IP` to connect to the service. I propose that when clients are disable, the synccatalog falls back to the consul server service. When `client.enabled=true` the syncCatalog should make use of the HOST_IP to connect with consul. When `client.enabled=false` the syncCatalog should fall back to the consul server service.
Enable setting a specific address in a service definition for advertise.
If no specific address is given it will fallback to the node address and reassemble the old behaviour.
This does provide functionality to have consul running on a separate private interface and advertise services for a different public/private one during service discovery.
example for two services on the same node that advertise different addresses:
consul bound to localhost via configuration file:
The result of a service discovery via DNS:
external-service results in
10.0.1.4
because of the specific address in the service definition.default-service results in
127.0.0.1
where the service defaults to the node address which is127.0.0.1
.