Skip to content

Commit 856951b

Browse files
author
Neil Jerram
committed
Give the node a chance to indicate its own canonical IPs
1 parent 0bf0876 commit 856951b

File tree

1 file changed

+8
-0
lines changed
  • pkg/cluster/internal/providers/docker

1 file changed

+8
-0
lines changed

pkg/cluster/internal/providers/docker/node.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ func (n *node) Role() (string, error) {
5151
}
5252

5353
func (n *node) IP() (ipv4 string, ipv6 string, err error) {
54+
// Give the node a chance to indicate its own canonical IPs.
55+
output, err := exec.Output(exec.Command("docker", "exec", n.name, "/get-ips.sh"))
56+
if err == nil {
57+
ips := strings.Split(strings.TrimSpace(string(output)), " ")
58+
fmt.Printf("Node %v provided IPs: %v\n", n.name, ips)
59+
return ips[0], ips[1], nil
60+
}
61+
5462
// retrieve the IP address of the node using docker inspect
5563
cmd := exec.Command("docker", "inspect",
5664
"-f", "{{range .NetworkSettings.Networks}}{{.IPAddress}},{{.GlobalIPv6Address}}{{end}}",

0 commit comments

Comments
 (0)