Skip to content

This project should help you get WSL2, Docker, Kubernetes, Minikube, and Skaffold up and running.

License

Notifications You must be signed in to change notification settings

cheslijones/wsl2-minikube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Windows
  • kubectl
  • 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.

  1. git clone https://github.com/cheslijones/wsl2-minikube.git

  2. cd wsl2-minikube

  3. Install docker directly into WSL2:

    Run the following command so you don't have to use sudo for docker 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
    
  4. Install kubectl for Linux in WSL2

  5. 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.

  6. Install skaffold for Linux in WSL2

  7. 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
    
  8. Run skaffold dev.

  9. In another terminal, run minikube tunnel which should prompt you for sudo 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: 
    
  10. 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 with minikube start.

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.

About

This project should help you get WSL2, Docker, Kubernetes, Minikube, and Skaffold up and running.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages