Skip to content

Commit

Permalink
Give the node a chance to indicate its own canonical IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Jerram committed Feb 22, 2021
1 parent 0bf0876 commit 856951b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/cluster/internal/providers/docker/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func (n *node) Role() (string, error) {
}

func (n *node) IP() (ipv4 string, ipv6 string, err error) {
// Give the node a chance to indicate its own canonical IPs.
output, err := exec.Output(exec.Command("docker", "exec", n.name, "/get-ips.sh"))
if err == nil {
ips := strings.Split(strings.TrimSpace(string(output)), " ")
fmt.Printf("Node %v provided IPs: %v\n", n.name, ips)
return ips[0], ips[1], nil
}

// retrieve the IP address of the node using docker inspect
cmd := exec.Command("docker", "inspect",
"-f", "{{range .NetworkSettings.Networks}}{{.IPAddress}},{{.GlobalIPv6Address}}{{end}}",
Expand Down

0 comments on commit 856951b

Please sign in to comment.