How to share Minikube instance on both Docker for Windows and WSL2?

9/1/2021

How to share a Minikube instance amongst Windows/Windows WSL?

In Windows WSL minikube start fails:

😄  minikube v1.22.0 on Ubuntu 20.04
Using the docker driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🏃  Updating the running docker "minikube" container ...
🤦  StartHost failed, but will try again: provision: Temporary Error: NewSession: new client: new client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
🏃  Updating the running docker "minikube" container ...
😿  Failed to start docker container. Running "minikube delete" may fix it: provision: Temporary Error: NewSession: new client: new client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

❌  Exiting due to IF_SSH_AUTH: Failed to start host: provision: Temporary Error: NewSession: new client: new client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
💡  Suggestion: Your host is failing to route packets to the minikube VM. If you have VPN software, try turning it off or configuring it so that it does not re-route traffic to the VM IP. If not, check your VM environment routing options.
📘  Documentation: https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/
🍿  Related issue: https://github.com/kubernetes/minikube/issues/3930

The above works in Windows:

😄  minikube v1.17.1 on Microsoft Windows 10 Pro 10.0.19042 Build 19042
🎉  minikube 1.22.0 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.22.0
💡  To disable this notice, run: 'minikube config set WantUpdateNotification false'

Using the docker driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🏃  Updating the running docker "minikube" container ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, dashboard, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Questions:

  • Why would it fail on Linux? Note: I originally installed Minikube on Windows.
  • Is there a way to share the Minikube environment?

Second I want to share one Docker context. docker context ls:

Windows: Returns:

NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                             KUBERNETES ENDPOINT                 ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine              https://127.0.0.1:53873 (default)   swarm
desktop-linux       moby                                                          npipe:////./pipe/dockerDesktopLinuxEngine

Windows WSL (Ubuntu):

docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                             KUBERNETES ENDPOINT                 ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                 https://127.0.0.1:51967 (default)   swarm
desktop-linux       moby

Questions:

  • What is default?
  • What is desktop-linux?
  • Which one is recommended to fully utilize the performance boost of WSL?

Third I want to share one Kubernetes context. kubectl config get-contexts:

Windows:

CURRENT   NAME                                       CLUSTER          AUTHINFO                        NAMESPACE
          docker-desktop                             docker-desktop   docker-desktop
          kubernetes/REDACTED   kubernetes       REDACTED
*         minikube                                   minikube         minikube                        default

Windows WSL (Ubuntu):

CURRENT   NAME             CLUSTER          AUTHINFO         NAMESPACE
          docker-desktop   docker-desktop   docker-desktop
*         minikube         minikube         minikube

Questions:

  • What is docker-desktop?
  • Can I safely delete docker-desktop?
-- Exegesis
docker
kubernetes
minikube

1 Answer

4/1/2022

I was able to synchronize both Windows/WSL by copying the configuration files:

mkdir ~/.kube \ && cp /mnt/c/Users/[USERNAME]/.kube/config ~/.kube
kubectl config use-context docker-for-desktop # Select the Windows context
kubectl cluster-info # Check if it works## Heading ##

Ref: https://devkimchi.com/2018/06/05/running-kubernetes-on-wsl/

-- Exegesis
Source: StackOverflow