loading...

WSL 2 Docker Docker Kubernetes on WSL 2

mikeyglitz profile image mikeyGlitz Updated on ・3 min read

Windows Subsystem for Linux (WSL) is a component which was introduced in Windows 10 that provides a Linux environment for development on Windows. The Linux environment works by proxying Linux kernel commands to the Windows kernel.

WSL2 is the second iteration over WSL which creates a virtualized Linux environment and new features such as filesystem access using the native Windows explorer application, Docker and more. WSL2 also provides notable performance improvements over the first version.

This guide will go over what is required to set up a functioning Kubernetes development environment using Windows 10, WSL2, Visual Studio Code, and Docker.

Installing WSL

[ Edit ]: I've heard news that the may 2020 release of Windows 10 was just released. WSL 2 should be considered GA now.
⚠ At the time of writing, WSL2 is currently a release preview with anticipated General Availability release planned for Summer 2020. WSL2 can be downloaded by first moving into the "Release Preview" ring of the Windows Insider Program. WSL2 requires Windows build 2004 or later.

After the upgrade to Windows build 2004, WSL can be installed using the following instructions https://docs.microsoft.com/en-us/windows/wsl/install-win10

Due to past experiences, I've installed Debian for its performance and ease-of-use.

Installing Docker

With WSL2 installed, Docker will need to be installed. Docker is a tool used to create, run, and orchestrate containers. Containers are self-contained environments that applications can run on. Docker can be downloaded from the download page

Once Docker is download it, install it by running the downloaded executable file. During the docker installation process, a prompt will display asking whether to enable the WSL 2 backend or not. Select yes when this prompt is displayed.

The WSL backend for Docker can also be turned on post-install by accessing the settings menu

Docker Settings

From the settings menu, select the General tab and check the box next to Use the WSL 2 based engine

WSL2 Engine

Enabling Kubernetes

Once Docker has been installed and the WSL 2 Backend has been enabled, Kubernetes on Docker can be enabled by switching to the Kubernetes tab on the Docker settings window and checking the Enable Kubernetes checkbox.

Enable Kubernetes Setting

Advantages of Kubernetes in Docker

Using Kubernetes in Docker means skipping on complicated installation instructions such as setting up CLI tools like kubeadm or k3s.

Using Kubernetes in Docker also means not having to set up a CNI layer such as calico, or flannel.

Docker provides a load balancer which allows traffic to be ingressed through localhost.

Docker for Windows will also set up the CLI tools which are used with both Kubernetes and Docker such as the Docker CLI and kubectl once the container engine is running.

Advantages of Kubernetes in WSL 2

I migrated from using Kubernetes in Minikube. I found Minikube -- even with the HyperV backend to be cumbersome and resource intensive.

WSL by comparison allowed me to deploy more containers so that I can test multiple applications at a time.

Discussion

markdown guide
 

If you liked this post and want to see more, I'm working on a playground project to continue my Kubernetes journey on GitHub
github.com/mikeyglitz/kube-playground