VSCode devcontainer connect to kubernetes cluster on vm

1/22/2020

Ultimate Goal

From a dotnet/core/sdk devcontainer (using VSCode Remote Containers), debug a .NET Core app running in a kubernetes cluster hosted on another vm of my host machine.

Current Setup

  • Docker Desktop for Windows running via Hyper-V
    • default DockerNAT network adapter
  • Ubuntu VM (multipass) running on same Hyper-V host
    • microk8s cluster running on this ubuntu instance
    • default "Default Switch" network adapter

Errors

  • When I try to ping the ubuntu vm from a docker container by hostname, the IP is resolved properly but I get the error "Destination Host Unreachable"
  • When I try to curl the cluster api, I get the error "No route to host"
-- matrumz
hyper-v
kubernetes
vscode-debugger
vscode-remote

1 Answer

1/27/2020

I put this problem aside for a week, and over that time the host has been rebooted multiple times, but no further modifications were made to the networking, Hyper-V setup, etc.

Starting the Ubuntu VM today, the IP changed from what used to be 172.?.?.? to 192.168.92.x . I do not know what caused this change.

Now, Docker Desktop containers can ping the Ubuntu VM and curl the microk8s /api endpoint. Until such a time that I can reproduce the issue, I will mark this question as "solved" and reopen and try Nick's recommended solution if the issue returns.

-- matrumz
Source: StackOverflow