Running k3s inside WSL2 on a Surface Pro X

I’m a proud owner of a Surafe Pro X SQ2 which is an ARM64 device. If you’ve been reading me, you know I like to tinker with kubernetes and therefore I needed a solution for this device.

I remembered reading about k3s a lightweight kubernetes distro built for IoT & Edge computing, and decided to give it a try.

Installing k3s in WSL2

Download the binaries

1wget https://github.com/k3s-io/k3s/releases/download/v1.19.10%2Bk3s1/k3s-arm64

Rename the file

1mv k3s-arm64 k3s

Make the file executable

1chmod +x k3s

Move the file to /usr/local/bin

1sudo mv k3s /usr/local/bin

Copy to k3s config file to $HOME/.kube

1sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube

Make current user owner of the k3s config file

1sudo chown $USER $HOME/.kube/k3s.yaml

Running k3s

Run the k3s kubernetes server

1sudo k3s server

Test k3s

From another WSL2 console window:

Add the k3s config file to KUBECONFIG environment variable

1export KUBECONFIG=$HOME/.kube/config:$HOME/.kube/k3s.yaml

Use k3s context

1kubectl config use-context default

Check all running pods

1kubectl get po --all-namespaces

you should get an output similar to this one:

1NAMESPACE     NAME                                     READY   STATUS      RESTARTS   AGE
2kube-system   helm-install-traefik-mhhfz               0/1     Completed   0          20d
3kube-system   metrics-server-7b4f8b595-7cfsb           1/1     Running     1          20d
4kube-system   svclb-traefik-pqn56                      2/2     Running     2          20d
5kube-system   coredns-66c464876b-pnpgm                 1/1     Running     1          20d
6kube-system   local-path-provisioner-7ff9579c6-nhnbj   1/1     Running     6          20d
7kube-system   traefik-5dd496474-94lt5                  1/1     Running     1          20d

Note: k3s uses: local-path-provisioner and saves volume data in the /var/lib/rancher/k3s/data folder

Hope it helps!!!


Deploy AKS + Kubecost with Terraform
KCD 2021: Event driven Microservices with Dapr and .NET
comments powered by Disqus