All the configuration around WSL2 to get it to play nice with k8s is full of gotchas. (believe me I tried). https://linuxconfig.org/how-to-install-kubernetes-on-ubuntu-22-04-jammy-jellyfish-linux
Instead, relying on some other project that has done it already makes the most sense. :)
Choices then are:
- Minikube
- Docker for Desktop
- Rancher Desktop
I went with the 3rd option. Rancher Desktop. Mostly because of licensing/cost reasons. It also sounded like it was in more use by companies than minikube.
https://docs.rancherdesktop.io/getting-started/installation/
https://github.com/rancher-sandbox/rancher-desktop/releases
Before running the installer (v1.5.1), having WSL2 installed and configured was nice. And I got a ubuntu box ready in WSL2.
The installer worked pretty well, but it goes blank for an extended period of time before coming up or I had to relaunch the installer after waiting for 5 minutes of nothing happening.
After it came up, I Enabled Kubernetes
with the latest stable version (v1.24.6)
and added access to the WSL2 instance I had made previously.
Everything went well.
Here is a big dump of text showing the first tutorial https://docs.rancherdesktop.io/tutorials/working-with-images after I ran the installer:
phyatt at mypc in ~
$ nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
phyatt at mypc in ~/src
$ git clone https://github.com/rancher-sandbox/docs.rancherdesktop.io.git
Cloning into 'docs.rancherdesktop.io'...
remote: Enumerating objects: 4563, done.
remote: Counting objects: 100% (1455/1455), done.
remote: Compressing objects: 100% (397/397), done.
remote: Total 4563 (delta 797), reused 1331 (delta 753), pack-reused 3108
Receiving objects: 100% (4563/4563), 6.58 MiB | 2.94 MiB/s, done.
Resolving deltas: 100% (2518/2518), done.
phyatt at mypc in ~/src
$ cd docs.rancherdesktop.io/
phyatt at mypc in ~/src/docs.rancherdesktop.io on main
$ cd assets/express-sample/
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ ls
app.js bin Dockerfile manifests.yaml package.json public routes views
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ nerdctl --namespace k8s.io build -t expressapp:v1.0 .
[+] Building 23.9s (11/11) FINISHED
=> [internal] load .dockerignore 0.2s
=> => transferring context: 343B 0.0s
=> [internal] load build definition from Dockerfile 0.4s
=> => transferring dockerfile: 323B 0.0s
=> [internal] load metadata for docker.io/library/node:lts-alpine 1.3s
=> [1/6] FROM docker.io/library/node:lts-alpine@sha256:4d68856f48be7c73cd83ba8af3b6bae98f4679e14d1ff49e164625ae 10.0s
=> => resolve docker.io/library/node:lts-alpine@sha256:4d68856f48be7c73cd83ba8af3b6bae98f4679e14d1ff49e164625ae8 0.0s
=> => sha256:8de0f21617f6907153a9421a9a8747128344a62083d9b73d28a7666c0c8cdfd5 452B / 452B 21.8s
=> => sha256:9f61bc6ef19c925a11b522821474ce4bbace586692b3bd96c888a10f20bc9a5f 2.35MB / 2.35MB 21.7s
=> => sha256:bb60732a8e9f2776343d1c7edb82783f0d53d69800cf6050ad924606b9c92573 36.45MB / 36.45MB 21.5s
=> => sha256:213ec9aee27d8be045c6a92b7eac22c9a64b44558193775a1a7f626352392b49 2.81MB / 2.81MB 1.3s
=> => extracting sha256:213ec9aee27d8be045c6a92b7eac22c9a64b44558193775a1a7f626352392b49 0.2s
=> => extracting sha256:bb60732a8e9f2776343d1c7edb82783f0d53d69800cf6050ad924606b9c92573 2.0s
=> => extracting sha256:9f61bc6ef19c925a11b522821474ce4bbace586692b3bd96c888a10f20bc9a5f 0.1s
=> => extracting sha256:8de0f21617f6907153a9421a9a8747128344a62083d9b73d28a7666c0c8cdfd5 0.1s
=> [internal] load build context 0.2s
=> => transferring context: 4.98kB 0.0s
=> [2/6] WORKDIR /usr/src/app 1.8s
=> [3/6] COPY [package.json, package-lock.json*, npm-shrinkwrap.json*, ./] 0.2s
=> [4/6] RUN npm install --production --silent && mv node_modules ../ 6.7s
=> [5/6] COPY . . 0.2s
=> [6/6] RUN chown -R node /usr/src/app 0.5s
=> exporting to oci image format 2.9s
=> => exporting layers 1.1s
=> => exporting manifest sha256:40ce02476eb2587b1b3af1a584a490c9bd5af90d4db7f286505234da49963438 0.0s
=> => exporting config sha256:5ea16c98cb1ae49a7636965bfb12c9ad213f0c0c09ac755cb2ffe5b4cdd4307d 0.0s
=> => sending tarball 1.7s
unpacking docker.io/library/expressapp:v1.0 (sha256:40ce02476eb2587b1b3af1a584a490c9bd5af90d4db7f286505234da49963438)...done
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ kubectl get pod
No resources found in default namespace.
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system local-path-provisioner-7b7dc8d6f5-hvvc9 1/1 Running 0 19m
kube-system coredns-b96499967-tkcxd 1/1 Running 0 19m
kube-system helm-install-traefik-crd-zmwcl 0/1 Completed 0 19m
kube-system metrics-server-668d979685-tfd6p 1/1 Running 0 19m
kube-system svclb-traefik-b716f8b8-fghg9 2/2 Running 0 18m
kube-system helm-install-traefik-tdbjb 0/1 Completed 2 19m
kube-system traefik-7cd4fcff68-2pd9h 1/1 Running 0 18m
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ kubectl run --image expressapp:v1.0 expressapp
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
expressapp 1/1 Running 0 14s
phyatt at mypc in ~/src/docs.rancherdesktop.io/assets/express-sample on main
$ kubectl port-forward pods/expressapp 3000:3000 &
[1] 4542