Skip to content

Commit

Permalink
add for port forwarding as well
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Jan 5, 2022
1 parent 807c056 commit e3b7887
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/minikube/driver/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ func ControlPlaneEndpoint(cc *config.ClusterConfig, cp *config.Node, driverName
}
hostname := oci.DaemonHost(driverName)

ip := net.ParseIP(hostname)
if ip == nil {
return hostname, ip, port, fmt.Errorf("failed to parse ip for %q", hostname)
ips, err := net.LookupIP(hostname)
if err != nil || len(ips) == 0 {
return hostname, nil, port, fmt.Errorf("failed to lookup ip for %q", hostname)
}

// https://github.com/kubernetes/minikube/issues/3878
if cc.KubernetesConfig.APIServerName != constants.APIServerName {
hostname = cc.KubernetesConfig.APIServerName
}
return hostname, ip, port, err
return hostname, ips[0], port, err
}

// https://github.com/kubernetes/minikube/issues/3878
Expand All @@ -56,9 +56,7 @@ func ControlPlaneEndpoint(cc *config.ClusterConfig, cp *config.Node, driverName
if err != nil || len(ips) == 0 {
return hostname, nil, cp.Port, fmt.Errorf("failed to lookup ip for %q", cp.IP)
}
// get last IP as it's IPv4
ip := ips[len(ips)-1]
return hostname, ip, cp.Port, nil
return hostname, ips[0], cp.Port, nil
}

// AutoPauseProxyEndpoint returns the endpoint for the auto-pause (reverse proxy to api-sever)
Expand Down

0 comments on commit e3b7887

Please sign in to comment.