Running k3s on Windows with WSL2

Update 2024: Another good alternative to Rancher Desktop is to run K3s via k3d project. It allows to create potentially multiple K3s clusters in docker. In example, to create a cluster you would simply type:

k3d cluster create -p "8087:80@loadbalancer"

That would expose its port 80 on your port 8087.

Update 2021-12-20: While the instructions below still work, the current recommended way to use k3s on Windows is via Rancher Desktop.

The original instructions were for microk8s but I had glitches with its operations on Windows.
So I replaced microk8s with k3s and it worked.
Algorithm of installation goes as following:
1. Install WSL2 – instructions here: https://docs.microsoft.com/en-us/windows/wsl/install-win10 (note that you need specific versions of Windows 10 referenced in the document). One of key bonuses right away with WSL2 – you now may have full docker running on Windows Home!

2. One thing I recommend right away after installing WSL2 – set some sane memory and CPU limits for it, otherwise it becomes resource hog quickly. How you can read here – https://medium.com/@lewwybogus/how-to-stop-wsl2-from-hogging-all-your-ram-with-docker-d7846b9c5b37

3. Set up your favorite Ubuntu 18.04 from Microsoft Store. Here comes surprise – it comes with systemd disabled and not working snaps.

4. To obtain systemd I tried bunch of articles, and finally this one worked – https://forum.snapcraft.io/t/running-snaps-on-wsl2-insiders-only-for-now/13033 (would appreciate feedback on this one, since I had few other things on my system by the time I tried this one – but hopefully it works right away).

5. Finally install k3s as usual as described at https://k3s.io/ .

6. Note, that to reach k3s cluster from your browser or powershell on host you would need to note ip of Ubuntu vm, which can be found for example by running ifconfig.

2 comments

Leave a comment

Your email address will not be published. Required fields are marked *