-
Notifications
You must be signed in to change notification settings - Fork 392
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
etcd: Add initial support for an IPv6 control plane #1211
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,9 +156,34 @@ func runRunCmd(cmd *cobra.Command, args []string) error { | |
return err | ||
} | ||
|
||
parsedIP := net.ParseIP(setupEnv.etcdIP) | ||
if parsedIP == nil { | ||
return fmt.Errorf("Failed to parse IP '%s'", setupEnv.etcdIP) | ||
} | ||
|
||
escapedIP := setupEnv.etcdIP | ||
escapedAllIPs := "0.0.0.0" | ||
localhostIP := "127.0.0.1" | ||
escapedLocalhostIP := "127.0.0.1" | ||
if parsedIP.To4() == nil { | ||
// This is an IPv6 address, not IPv4. | ||
|
||
// When using an IPv6 address in a URL, we must wrap the address portion in | ||
// [::] so that a ":port" suffix can still be added and parsed correctly. | ||
escapedIP = fmt.Sprintf("[%s]", setupEnv.etcdIP) | ||
escapedAllIPs = "[::]" | ||
localhostIP = "::1" | ||
escapedLocalhostIP = "[::1]" | ||
} | ||
|
||
unexportedEnv := map[string]string{ | ||
"IPV4_ADDRESS": setupEnv.etcdIP, | ||
"WILDCARD_DNS_NAME": fmt.Sprintf("*.%s", setupEnv.opts.discoverySRV), | ||
// TODO This can actually be IPv6, so we should rename this ... | ||
"IPV4_ADDRESS": setupEnv.etcdIP, | ||
"ESCAPED_IP_ADDRESS": escapedIP, | ||
"ESCAPED_ALL_IPS": escapedAllIPs, | ||
"LOCALHOST_IP": localhostIP, | ||
"ESCAPED_LOCALHOST_IP": escapedLocalhostIP, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. confused why we need both, is it possible to conditionally set LOCALHOST_IP and conditionally escape it if ipv6? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's kind of annoying, because we only want to use it in its escaped form in some cases (in a URL), but not when it's provided as a raw IP, that's why it's there twice |
||
"WILDCARD_DNS_NAME": fmt.Sprintf("*.%s", setupEnv.opts.discoverySRV), | ||
} | ||
if setupEnv.etcdDNS != "" { | ||
unexportedEnv["DNS_NAME"] = setupEnv.etcdDNS | ||
|
@@ -338,10 +363,6 @@ func ipAddrs(preferredIP string) ([]string, error) { | |
if ip == nil { | ||
continue | ||
} | ||
ip = ip.To4() | ||
if ip == nil { | ||
continue // not an ipv4 address | ||
} | ||
if !ip.IsGlobalUnicast() { | ||
continue // we only want global unicast address | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ path: "/etc/sysctl.d/forward.conf" | |
contents: | ||
inline: | | ||
net.ipv4.ip_forward = 1 | ||
net.ipv6.conf.all.forwarding = 1 | ||
|
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.
It would really help readability if instead of
ESCAPED_ALL_IPS
we haveLISTEN_CLIENT_URLS
andLISTEN_PEER_URLS
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.
we'd need LISTEN_CLIENT_URLS, LISETN_PEER_URLS, LISTEN_METRIC_URLS, and METRICS_ADDR. sure you want 4 variables instead of this 1?
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.
@russellb thanks for pointing out, I thought it would make the naming more explicit but having 4 variables instead of 1 would be an overdo. Feel free to mark it resolved.