K3S on Win 10 WSL 2

Published: Sep 8, 2019 by Isaac Johnson

In our last post we dived into k3s - running it from a docker container with k3d and from both Pi (ARM64) and Google Cloud.  But what about from Windows? Is it possible to spin a reasonable cluster up in Windows 10?

WSL 2

Windows Subsystem for Linux 2 is actually the yet-to-be released version of WSL already in Windows 10.  You need to be in an Insider Preview version of Windows presently to use it (b 18917 or higher)

Getting into Windows Insider

First, you’ll need to get into the Windows Insider Fast Ringto get WSL 2.0.  

You can find it in Windows Update, under advanced options.  First get into the Insider Program by signing up and agreeing to a lengthy terms sheet that says that indeed, yes your machine won’t be as stable.  Then change your Update Settings to “Fast”

You’ll have a few restarts, but when done, you’ll be living large in preview land.  You’ll see the build in the bottom right of your screen as well.

Next, you’ll need to upgrade your existing Ubuntu instance in WSL if you’ve already been running WSL.  

If you get any errors, you’ll likely need to uncompress the folder that holds the linux images to do the inline upgrade.  

You’ll head to %USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited… and right click any Ubuntu (or other distro) folders to choose to uncompress them:

(uncheck Compress and Apply to all and sit back and wait a good long while).

Upgrading an existing Ubuntu (WSL 1 to 2)

Launch an Admin Powershell and run:

wsl --set-version Ubuntu 2

Installing a new ubuntu

First, make sure to set the WSL default version to 2.

Launch an Admin Powershell and run:

wsl --set-default-version 2

Then you can search and install Ubuntu from the App Store:

Running k3s

I generally make a folder under a root drive, e.g. /mnt/d/k3s

Then download k3s binary from https://github.com/rancher/k3s/releases/latest

chmod +x k3s

Lastly run it:

sudo ./k3s server

Using our k3s.

You can use it in WSL or Windows itself. Just get the config file from /etc/rancher/k3s/k3s.yaml once k3s is running:

Then put that in your %USERHOME%.kube\config and use kubectl as normal:

Summary

k3s runs quiet well in WSL.  Having had it running over a week now, i’ve found the main issue is the Windows Insider program continues to reboot my machine far too often.  One can set active hours which at least limits when it reboots. However, it’s hard to have a cluster to remotely access that requires one to continually log in to start back up in WSL.

I think this will be a fantastic option once WSL 2 is finally released outside of fast ring.

k3s getting-started tutorial

Have something to add? Feedback? You can use the feedback form

Isaac Johnson

Isaac Johnson

Cloud Solutions Architect

Isaac is a CSA and DevOps engineer who focuses on cloud migrations and devops processes. He also is a dad to three wonderful daughters (hence the references to Princess King sprinkled throughout the blog).

Theme built by C.S. Rhymes