Skip to content

Commit

Permalink
Merge pull request #12319 from andriyDev/UseWSLIP
Browse files Browse the repository at this point in the history
Select WSL VM IP when performing mounting
  • Loading branch information
medyagh authored Aug 24, 2021
2 parents c8a405a + 4052359 commit 01155b1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/minikube/cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/detect"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/mustload"
Expand Down Expand Up @@ -111,7 +112,19 @@ var mountCmd = &cobra.Command{
var ip net.IP
var err error
if mountIP == "" {
ip, err = cluster.HostIP(co.CP.Host, co.Config.Name)
if detect.IsMicrosoftWSL() {
klog.Infof("Selecting IP for WSL. This may be incorrect...")
ip, err = func() (net.IP, error) {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
return nil, err
}
defer conn.Close()
return conn.LocalAddr().(*net.UDPAddr).IP, nil
}()
} else {
ip, err = cluster.HostIP(co.CP.Host, co.Config.Name)
}
if err != nil {
exit.Error(reason.IfHostIP, "Error getting the host IP address to use from within the VM", err)
}
Expand Down

0 comments on commit 01155b1

Please sign in to comment.