rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.88k stars 275 forks source link

Epic: Use Lima host resolver on Windows #1899

Closed jandubois closed 2 years ago

jandubois commented 2 years ago

We want to use the Lima host resolver to take advantage of all the DNS configuration on the host itself (automatic support of split-DNS over VPN etc).

The resolver code should be in a separate repo at https://github.com/rancher-sandbox/rancher-desktop-host-resolver. It currently uses a fork of pkg/hostagent/dns.go from Lima to allow rapid development. Once this task is complete, any changes should be back-ported upstream.

NOTE: For the above item, a different approach was taken. To avoid filtration of the incoming DNS requests. The host-resolver runs two processes, 1) In wsl distro 2) on the windows host machine, the communication happens over a dedicated AF_VSOCK connection, therefore the process that runs on the windows host machine can only accept DNS lookups that are incoming over the AF_VSOCK connection.

Nino-K commented 2 years ago

How to enable this feature:

This feature can be enabled through a configuration property experimentalHostResolver in %APPDATA%\rancher-desktop\settings.json. By default this property is set to false, meaning that the default DNS process in the rancher desktop will be handled through dnsmasq. However, if this property is set to true the default DNS lookup will switch to host-resolver.

NOTE: This feature can only be enabled for Windows currently and it is an experimental feature.

You can take a look at the example settings.json file below as a reference:

{
   "version":4,
   "kubernetes":{
      "version":"1.22.7",
      "memoryInGB":2,
      "numberCPUs":2,
      "port":6443,
      "containerEngine":"moby",
      "checkForExistingKimBuilder":false,
      "enabled":true,
      "WSLIntegrations":{
         "Ubuntu":true
      },
      "options":{
         "traefik":true,
         "flannel":true
      },
      "suppressSudo":false,
      "experimentalHostResolver":true           <== This is the config!
   },
   "portForwarding":{
      "includeKubernetesServices":false
   },
   "images":{
      "showAll":true,
      "namespace":"k8s.io"
   },
   "telemetry":true,
   "updater":false,
   "debug":false,
   "pathManagementStrategy":"notset"
}

After applying the configuration changes above you must restart Rancher Desktop for the changes to take place.

Nino-K commented 2 years ago

Related PRs:

PR #2079 rancher-desktop PR #7 rancher-desktop-host-resolver

jandubois commented 2 years ago

NOTE: This feature can only be enabled for Windows currently and it is an experimental feature.

It is already the default on Linux and macOS.

CaringDev commented 2 years ago

On Windows %APPDATA%\rancher-desktop\settings.json