-
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
Add support for dual stack IPv4/IPv6 network #6640
Conversation
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.
@mkeeler is it what you had in mind? (modulo the missing DNS)
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.
This is exactly what I had in mind. There are a few places in the PR where we need some additional logic to chose the "best" address which will be needed in particular for DNS. I have added comments to a few of those locations.
Right now we select the best address in the following order:
For WAN:
- "wan" tagged address of the
NodeService
Address
field on theNodeService
- "wan" tagged address of the
Node
Address
field on theNode
For LAN
Address
field on theNodeService
Address
field on theNode
I actually think my original implementation missed using a tagged "lan" address. Regardless I think we want Address selection to now have the following precedence.
For WAN + IPv6 Preference
- "wan_ipv6" tagged address of the
NodeService
- "wan" tagged address of the service (if IPv6)
Address
field of theNodeService
(if its IPv6)- "wan_ipv6" tagged address of the
Node
- "wan" tagged address of the
Node
(if its IPv6) Address
field on theNode
(if its IPv6)
For WAN + No IPv6 Preference
- "wan_ipv4" tagged address of the
NodeService
- "wan" tagged address of the service (if IPv4)
Address
field of theNodeService
(if its IPv4)- "wan_ipv4" tagged address of the
Node
- "wan" tagged address of the
Node
(if its IPv4) Address
field on theNode
(if its IPv4)
For LAN + IPv6 Preference
- "lan_ipv6" tagged address of the
NodeService
- "lan" tagged address of the service (if IPv6)
Address
field of theNodeService
(if its IPv6)- "lan_ipv6" tagged address of the
Node
- "lan" tagged address of the
Node
(if its IPv6) Address
field on theNode
(if its IPv6)
For LAN + No IPv6 Preference
- "lan_ipv4" tagged address of the
NodeService
- "lan" tagged address of the service (if IPv4)
Address
field of theNodeService
(if its IPv4)- "lan_ipv4" tagged address of the
Node
- "lan" tagged address of the
Node
(if its IPv4) Address
field on theNode
(if its IPv4)
Also for xDS/Envoy I don't think there is anything you need to do at least for Mesh Gateways. The gateways already have the option to bind to all tagged addresses. If you are looking to add dual-stack support to a connect proxies listener then that will take a bit more effort.
@@ -565,7 +574,7 @@ type Node struct { | |||
|
|||
func (n *Node) BestAddress(wan bool) string { |
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.
Maybe it would be useful to add a second argument to indicate whether IPv4 or IPv6 should be preferred.
@Aestek Possible to fix the conflict? |
70ccf18
to
d4c1c75
Compare
@Aestek let me know when you think this is good to go for another review. |
d4c1c75
to
bbffa37
Compare
@i0rek Good for review. I also added the DNS part. |
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.
LGTM
I only had the one comment but seeing as no other changes are needed I don't see a reason for that one thing to prevent merging.
@@ -2451,6 +2471,34 @@ func (a *Agent) validateService(service *structs.NodeService, chkTypes []*struct | |||
} | |||
} | |||
|
|||
// Check IPv4/IPv6 tagged addresses | |||
if service.TaggedAddresses != nil { |
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.
The nil check here should not be necessary as val, ok := service.TaggedAddresses[...]
will work fine even on a nil map.
This shouldn't need to block merging though.
Implementation for #6531
As described in the issue, we can only set one address for a service or a node. In cases were the network is dual stack IPv4/IPv6 we would like to specify addresses for both protocols.
We add config options for node :
advertise_addr_ipv4
advertise_addr_ipv6
advertise_addr_wan_ipv4
advertise_addr_wan_ipv6
These addresses are set in the TaggedAddress map and available in HTTP endpoints
For services, TaggedAddresses can be set directly when registering the service.
The keys for TaggedAddress entries are defined in the
structs
package :For both nodes and services, tagged addresses take default from the "address" field when compatible. For example, running an agent with
advertise_addr = "1.2.3.4"
will automatically setlan_ipv4
andwan_ipv4
, unless they are explicitly specified. For services the "Address" field is used.Left to do :