Purpose
This repo was originally intended to show the numerous issues one was faced with when trying to use WSL2 with minikube
.
Now, after several years and countless hours of testing to get issues worked out, it finally looks like WSL/WSL2 is usable for development (for my use case). Much appreciation to the developers of WSL2 and minikube
. I've actually deleted my Linux partition and started using WSL2 full-time.
My use case is the following stack:
docker
running in WSL2 and not Docker Desktop for Windowskubectl
minikube
skaffold
mkcert
for local development TLS certificates
I'm repurposing this repo to demonstrate how to get this stack up and running in WSL2.
For the mkcert
implementation, please see this repo.
9/11/21 Update - It seems like this wasn't working properly so I fixed the issue.
11/30/21 Update - Clarified a few steps related to docker
and sudo
, and where kubectl
, minikube
, and skaffold
should be installed (WSL2).
Setup
Assuming WSL2 is already enabled and using WSL2 Ubuntu 20.04 LTS is already installed.
Refer to the documentation below for the latest installation processes.
-
git clone https://github.com/cheslijones/wsl2-minikube.git
-
cd wsl2-minikube
-
Install
docker
directly into WSL2:Run the following command so you don't have to use
sudo
fordocker
commands:sudo usermod -aG docker $USER
Then close and reopen WSL2, restart the Lxss service, or sign in and out of Windows... which ever works.
Of course, every time you boot up Windows you need to start
docker
in WSL2 with:sudo service docker start
-
Install
minikube
for Linux in WSL2:Go ahead and create a cluster while we are here.
minikube start --vm-driver=docker
It should spin up in about a minute.
-
Install / enable
ingress-nginx
:It is a bit counter-intuitive, but using the Docker for Mac instructions works not only with Docker Desktop for Windows and macOS, but also WSL2:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/cloud/deploy.yaml
-
Run
skaffold dev
. -
In another terminal, run
minikube tunnel
which should prompt you forsudo
credentials:$ minikube tunnel ❗ The service ingress-nginx-controller requires privileged ports to be exposed: [80 443] 🔑 sudo permission will be asked for it. 🏃 Starting tunnel for service ingress-nginx-controller. [sudo] password for cheslijones:
-
Open your preferred browser and navigate to
localhost
.You should see:
If not:
- Make sure
docker
is running (sudo service docker start
). - Make sure your
minikube
cluster is running withminikube start
.
- Make sure
Questions, Issues and Feedback
Please create an issue if you have any questions, issues running the repo, or have feedback on how I can improve this repo or correct something that is wrong. I'm always looking for ways to improve.