-
-
Notifications
You must be signed in to change notification settings - Fork 461
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
[BUG] WSL2: host.k3d.internal
warning & failed kubectl connection at 0.0.0.0
#858
Comments
@jadler-goodrx looks like other people are seeing this as well. |
I'm also seeing this, @keyiis does using |
@kslacroix After I changed kubeconfig host to |
What do you mean by kubeconfig host? |
@kslacroix |
@keyiis Ahh yeah this makes sense, thank you! For reference, this is where it fails for me... // GetHostIP returns the routable IP address to be able to access services running on the host system from inside the cluster.
// This depends on the Operating System and the chosen Runtime.
func GetHostIP(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) (net.IP, error) {
rtimeInfo, err := runtime.Info()
if err != nil {
return nil, err
}
l.Log().Tracef("GOOS: %s / Runtime OS: %s (%s)", goruntime.GOOS, rtimeInfo.OSType, rtimeInfo.OS)
isDockerDesktop := func(os string) bool {
return strings.ToLower(os) == "docker desktop"
}
// Docker Runtime
if runtime == runtimes.Docker {
// Docker (for Desktop) on MacOS or Windows
if isDockerDesktop(rtimeInfo.OS) {
toolsNode, err := EnsureToolsNode(ctx, runtime, cluster)
if err != nil {
return nil, fmt.Errorf("failed to ensure that k3d-tools node is running to get host IP :%w", err)
}
ip, err := resolveHostnameFromInside(ctx, runtime, toolsNode, "host.docker.internal", ResolveHostCmdGetEnt)
if err == nil {
return ip, nil
}
l.Log().Warnf("failed to resolve 'host.docker.internal' from inside the k3d-tools node: %v", err)
}
l.Log().Infof("HostIP: using network gateway...")
ip, err := runtime.GetHostIP(ctx, cluster.Network.Name)
if err != nil {
return nil, fmt.Errorf("runtime failed to get host IP: %w", err)
}
return ip, nil
}
// Catch all other runtime selections
return nil, fmt.Errorf("GetHostIP only implemented for the docker runtime")
} The line |
The way I fixed the issue on my end (without modifying kubeconfig) was to modify the coredns config-map.
Which returns the hostIP as seen from the docker VM. The IP was
|
humm.... I'm having the same problem. It worked fine before... Once I edited kubeconfig directly, I also confirmed that it works.
|
@heesuk-ahn what do you have to do to fix this? When I try to use an image I have loaded into the cluster I get the following error
|
same issue: WARN[0001] failed to resolve 'host.docker.internal' from inside the k3d-tools node: Failed to read address for 'host.docker.internal' from command output |
Up to version 5.0.1, the above code normally receives the value However, strangely in the later versions |
In my case, since k3d is executed inside the container, after changing the server host information in kubeconfig to |
Hi @keyiis , thanks for opening this issue and thanks to the others for providing more input on this! However, all the fuss about I think this issue actually covers two different problems, which I will investigate today 👍 |
@keyiis (and others!) are you running your commands in the WSL2 terminal or in PowerShell? |
Another few things to note here... Docker for Desktop has at least three possible variations:
Testing with WSL2 backend:
Other cases to consider:
Potential solution: making use of the |
host.k3d.internal
warning & failed kubectl connection at 0.0.0.0
@iwilltry42 hi, My development environment is used by installing k3d inside the alpine container and connecting to the docker daemon of the host (macOs). In this environment, if I change And my docker version is as below.
|
@iwilltry42 You're right, I misunderstood the issue at first. My problem is different from @keyiis especially since I'm on Macos. I was seeing these logs also
which made me think we had the same issue. Should I open a new issue or will your fix address my issue also? |
Your docker client (CLI) and kubectl are also running inside that alpine container?
It will be addressed by the linked PR 👍 |
thanks your advise :) I tried
How can I possibly solve this error? 🤔 |
@heesuk-ahn ah yes, didn't think of that... Instead of relying on the kubeconfig output by k3d upon k3d kubeconfig get mycluster | sed 's/0\.0\.0\.0/host.k3d.internal/' > /tmp/k3d-mycluster.yaml && \
KUBECONFIG=$KUBECONFIG:/tmp/k3d-mycluster.yaml kubectl config view --merge --flatten > $HOME/.kube/config Note: I did not test this, so better backup your kubeconfig first! |
What did you do
What did you expect to happen
kubectl cluster-info
can work.Screenshots or terminal output
Which OS & Architecture
My OS is win10,docker run in wsl2,I use dind mode to install k3d,I runing k3d container by
docker run ... -v /var/run/docker.sock:/var/run/docker.sock ...
,Therefore, K3D and nodes(k3d cluster node) are running at the same level.Which version of
k3d
Which version of docker
The text was updated successfully, but these errors were encountered: