DEV Community

Cover image for Running a Kubernetes local cluster on Windows
Christian Seki
Christian Seki

Posted on

Running a Kubernetes local cluster on Windows

Nowadays we can use WSL Windows Subsystem for Linux technology to run Kubernetes on Windows almost seamlessly! So let's do this 😎


📋 Installation
Known issues
🎡 Playing with kubernetes
✏️ Conclusion


⚠️ First of all check requirements for running WSL 2 ⚠️

▫️ For x64 systems: Version 1903 or higher, with Build 18362 or higher.
▫️ For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.

Configuration Stuff

  1. To install and enable WSL here's the official guide made by Microsoft: https://docs.microsoft.com/en-us/windows/wsl/install-win10
    • In this step, I choose the Ubuntu 20.04 distro.
  2. Install Docker Desktop on Windows: https://www.docker.com/products/docker-desktop
  3. Configuring Docker Desktop to use WSL
    • In Docker Desktop Settings
      • ▶️ General
      • Then select: Alt Text
      • ▶️ Resources
      • ➡️ WSL Integration
      • Then select: Alt Text
      • Apply and Restart!
  4. To check the previous step, open your wsl distro and execute docker version and kubectl version. Both binaries have been installed in your distro.
  5. Finally, just enable Kubernetes in Docker Desktop settings: Alt Text
  6. This may take a while so be patient.

Known issues

Be patient but don't wait forever. So if your kubernetes installation process stuck in "Kubernetes is starting.." go to the troubleshooting section, Get Suport and waiting for DIAGNOSTICS.
The output log from Docker Desktop, in my case:

cannot get lease for master node: an error on the server (\"\") has prevented the request from succeeding (get leases.coordination.k8s.io docker-desktop)
Enter fullscreen mode Exit fullscreen mode

You can try any of these solutions from stackoverflow:

https://stackoverflow.com/questions/55361963/kubernetes-is-starting-forever-error-on-windows-10

  • But I had to reset Docker Desktop to default to solve this issue 😥.

Playing with Kubernetes

You can use kubectl commands in wsl distro or directly from Windows, in this case you have to install the binary

kubectl config get-contexts the expected output is all clusters configured in your kubeconfig file but we're interested at:
Alt Text

kubectl get pods -n kube-system to see related kubernetes system
PODs.
kubectl cluster-info to get cluster information.
kubectl get nodes -o wide to get information about the single node running in our cluster.

Deploying a hello world app

kubectl run hello --image=tutum/hello-world --port=80
kubectl get pods to see the hello POD up and running
kubectl port-forward hello 8080:80 to forward local port 8080 to POD port 80 and make it accessible through http://localhost:8080/
kubectl logs hello to see the stdout from hello POD

Conclusion

I know we can't test all kubernetes power with a single node cluster but even with just a single node there's a lot of features and scenarios that we can test and I promise to write a more interesting example than a basic hello world someday.
I really had a great experience using WSL2 and if you are just like me that have to use Windows on the laptop for whatever reason I encourage you to try it!

Top comments (1)

Collapse
 
daddasoft profile image
Dadda Hicham

thank a lot. I'm looking for that