Install MicroK8s on WSL2
The Windows Subsystem For Linux Version 2 (also known as WSL2) supports running Ubuntu with systemd as the init process. This enables running snap (and MicroK8s!) natively on Windows hosts.
-
Install WSL2 on your machine following the instructions from Microsoft. Ensure that the installation completed successfully. Troubleshooting issues around WSL2 are beyond the scope of this document, but you will find lots of information on the WSL2 link above if you run into problems.
-
Update WSL to the latest version and ensure WSL2 is set as the default version:
wsl --update wsl --set-default-version 2
-
Install Ubuntu and wait for the machine to come up. Configure your username and password for the Ubuntu instance. Below, we choose username
ubuntu
: -
Enable systemd by running the following command in the WSL terminal:
echo -e "[boot]\nsystemd=true" | sudo tee /etc/wsl.conf
-
Exit the WSL terminal, then restart WSL.
wsl --shutdown wsl
From this point, systemd
is enabled and snaps should work properly. You can list the installed snaps with
sudo snap list
-
Install MicroK8s.
sudo snap install microk8s --classic
-
Wait for MicroK8s to start.
sudo microk8s status --wait-ready
We can also verify that our node is using the WSL2 kernel with:
sudo microk8s kubectl get node -o wide
-
Enable services and start using Kubernetes!
MicroK8s with a number of powerful addons out of the box. Enable the functionality you want to get started:
sudo microk8s enable dns sudo microk8s enable storage sudo microk8s enable dashboard
To access the dashboard, MicroK8s offers a helper command:
sudo microk8s dashboard-proxy
Open a browser window to the URL shown in the text and use the token to login:
MicroK8s wraps the
kubectl
binary, and you can use it to interact with the cluster:sudo microk8s kubectl create deploy --image nginx --replicas 3 nginx
What next?
- Want to experiment with alpha releases of Kubernetes? See the documentation on setting channels.
- Need to tweak the Kubernetes configuration? Find out how to configure the Kubernetes services.
- Having problems? Check out our troubleshooting section.
- Love MicroK8s? Want to contribute or suggest a feature? Give us your feedback.