Kubernetes on Windows: 6 Life-Saving Tools & Tips

Karl Hughes
Dec 15, 2021
10 Minute Read

Kubernetes is primarily a Linux technology, so it’s fairly straightforward to run it on different Linux distros. But what about the developers working on Windows who need to run Kubernetes locally? How can they run Kubernetes on Windows?

The good news is that they can, but it often requires meeting some prerequisites. This article will go through six different tools and tips that developers can use to run Kubernetes smoothly on Windows.

#What’s Different About Using Windows for Kubernetes?

Before diving into the details, let’s discuss what exactly makes running a Kubernetes cluster on Windows a challenge.

When we talk about containers, most of the time, we’re referring to Linux containers. You’re usually going to be running a Kubernetes cluster on a Linux host. But there can be scenarios where you choose to use Windows at the organization level for all types of workloads.

In those cases, you can run the Kubernetes cluster on a Windows host, but there is one limitation you should be aware of:

The Kubernetes control plane can only run a Linux host.

Your worker nodes can run on a Windows host, but you would need a Linux host on your Windows machine to run Kubernetes seamlessly. Different options are available to create a Linux virtual machine on a Windows host. For example, you can use a virtual box or WSL(Windows Subsystem for Linux), to name a few.

#Tools and Tips for Running Kubernetes on Windows

Now that you know what you’re facing, let’s get into the tools and techniques that can help you as a developer to run Kubernetes on Windows smoothly.

#1. Native Linux Commands with WSL

WSL allows you to run native Linux commands on Windows without setting up a virtual machine. WSL is a path-breaking functionality introduced in Windows by Microsoft, which makes the developer’s life easy.

Using Windows for your local development can be a blocker when developing cloud-native applications for Kubernetes. As mentioned previously, the Kubernetes control plane needs a Linux host; WSL helps in that part by providing you with some core Linux functionalities to run Kubernetes locally on Windows.

To install WSL on Windows, you need Windows 10 version 2004 and higher (build 19041 and higher) or Windows 11. Verify your Windows version and build number by pressing Windows logo key + R, then type winver and select OK. You may need to update Windows if you’re on the lower build version.

If your Windows build version is compatible, you can use the wsl-install command to install WSL. However, an older build of Windows may not support this command. To resolve it, follow the manual installation steps mentioned in the official documentation.

In most cases, the wsl-install command is enough to get up and running with WSL on Windows. It takes care of downloading the latest Linux kernel, setting WSL 2 as your default, and installing a Linux distribution for you.

Alternatively, you can change the default Linux distribution by downloading it from the Windows store. On the Microsoft Store home page, you can search for WSL and choose a distro from the available Linux distributions, such as Ubuntu, Debian, or Kali Linux.

Ubuntu Distro

When you launch a newly installed Linux distribution for the first time, a console window will open, and you’ll have to wait a bit for files to decompress and be stored on your PC. You will also have to create a user account and password for your new Linux distribution, as shown in the following screenshot.

Ubuntu installed

#2. Docker Desktop on Windows

Docker Desktop on Windows provides you with the option to create a single node functional Kubernetes cluster on your Windows workstation.

The following are the prerequisites for Docker Desktop on Windows:

  • Windows 10, updated to version 2004, Build 1903, or higher
  • Verify whether WSL is enabled or not by using the Turn Windows features on or off feature. Make sure that Windows Subsystem for Linux feature is turned on as shown in the following screenshot.

Enable WSL

Alternatively, to enable WSL on Windows, you can run the Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux command on PowerShell as an administrator.

Install a WSL distro from the Windows Store. Set up a username and password for your Linux distribution running in WSL.

While installing Docker Desktop on Windows, you can choose a WSL2 backend or Hyperv to create a Linux virtual machine. It’s recommended that you use a WSL2-based engine for better performance.

Once the Docker engine is up and running, enable the Kubernetes cluster by navigating to Settings. Click Kubernetes in the sidebar, then select the Enable Kubernetes checkbox. Click Apply & Restart.

Enable k8s

You should see two green lights at the bottom of the settings screen:

  • Engine running
  • Kubernetes running

You don’t have to install kubectl separately to interact with the Kubernetes cluster, as it’s taken care of by Docker Desktop itself. Verify the installation and setup by running the following kubectl commands in Windows Powershell:

PS C:\Users\ac> kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   2m36s
PS C:\Users\ac> kubectl get node
NAME             STATUS   ROLES                  AGE     VERSION
docker-desktop   Ready    control-plane,master   3m12s   v1.21.5

That’s it! Now you can start deploying your applications to a local Kubernetes cluster running on your Windows machine.

#3. Rancher Desktop

Rancher Desktop is an open-source desktop application for Kubernetes and container management with support for macOS and Windows.

The installation is pretty simple. After downloading and running the setup.exe, you will have the option to choose a Kubernetes version, as shown in the following screenshot.

Rancher k8s

This option of choosing a Kubernetes version is not supported with Docker Desktop. However, the benefit is that you can run the production Kubernetes version in your local Windows workstation.

You should see the following screen after choosing the Kubernetes version. It will first download the specific Kubernetes version for you. There are many options in the sidebar (.i.e., Kubernetes Settings, Images, etc.) to play with.

Rancher k8s install

You can again choose to use a different Kubernetes version by navigating to Kubernetes Settings as shown in the following screenshot.

Rancher k8s install

Apart from running a local Kubernetes cluster, you can build, push and pull images using Rancher Desktop.

#4. kind

Another Kubernetes SIGs project for running it locally, kind is short for Kubernetes in Docker. Instead of spawning a VM, you can run Kubernetes as a bunch of Docker containers. You get faster startup time with kind compared with minikube.

Since kind runs the Kubernetes cluster as Docker containers, you need to have Docker installed on your machine. On Windows, you can use the Chocolatey package manager to install kind on your local machine. If you don’t have Docker installed already, kind will install docker-desktop as well for you.

You can run the choco install kind -y command to install it. You should see the following output after running the command:

PS C:\WINDOWS\system32> choco install kind -y
Chocolatey v0.10.15
Installing the following packages:
kind
By installing you accept licenses for the packages.
Progress: Downloading kind 0.11.1... 100%

kind v0.11.1 [Approved]
kind package files install completed. Performing other installation steps.
Downloading kind 64 bit
  from 'https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-windows-amd64'
Progress: 100% - Completed download of C:\ProgramData\chocolatey\lib\kind\kind.exe (6.58 MB).
Download of kind.exe (6.58 MB) completed.
Hashes match.
 ShimGen has successfully created a shim for kind.exe
 The install of kind was successful.

To verify the kind setup, you can run the kind --version command. Now you’re ready to create local Kubernetes with kind using the kind create cluster command. Let’s run it.

PS C:\WINDOWS\system32> kind create cluster
Creating cluster "kind" ...
 • Ensuring node image (kindest/node:v1.21.1) 🖼  ...
 ✓ Ensuring node image (kindest/node:v1.21.1) 🖼
 • Preparing nodes 📦   ...
 ✓ Preparing nodes 📦
 • Writing configuration 📜  ...
 ✓ Writing configuration 📜
 • Starting control-plane 🕹️  ...
 ✓ Starting control-plane 🕹️
 • Installing CNI 🔌  ...
 ✓ Installing CNI 🔌
 • Installing StorageClass 💾  ...
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Thanks for using kind! 😊
PS C:\WINDOWS\system32> kubectl get nodes
NAME                 STATUS   ROLES                  AGE   VERSION
kind-control-plane   Ready    control-plane,master   27m   v1.21.1

kind requires at least 8 GB of RAM to run smoothly. Using the kind load docker-image my-image:latest command, you can directly load images to your cluster without pushing it to a registry.

#5. minikube

minikube is the most popular option for running the local Kubernetes cluster for the following reasons:

  • It can be deployed on VM, bare metal, or as a Docker container.
  • It supports different container runtimes(Docker, containerd, etc.).
  • It has out-of-the-box support for a Kubernetes dashboard and load balancing.
  • It supports various VM drivers.

For installation, you can directly download and run the .exe. Alternatively, you can use package managers like Chocolatey or Windows package manager.

Using Chocolatey, you can run the choco install minikube command to install minikube.

PS C:\WINDOWS\system32> choco install minikube
Chocolatey v0.10.15
Installing the following packages:
minikube
By installing you accept licenses for the packages.
Progress: Downloading kubernetes-cli 1.22.2... 100%
Progress: Downloading Minikube 1.23.2... 100%
.................
Minikube v1.23.2 [Approved]
minikube package files install completed. Performing other installation steps.
 ShimGen has successfully created a shim for minikube.exe
 The install of minikube was successful.

Now run the minikube start command to start a local Kubernetes cluster.

PS C:\WINDOWS\system32> minikube start --driver=docker
* minikube v1.23.2 on Microsoft Windows 10 Pro 10.0.18363 Build 18363
* Using the docker driver based on user configuration
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
    > gcr.io/k8s-minikube/kicbase: 355.40 MiB / 355.40 MiB  100.00% 3.32 MiB p/
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Preparing Kubernetes v1.22.2 on Docker 20.10.8 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
PS C:\WINDOWS\system32> kubectl get nodes
NAME       STATUS   ROLES                  AGE     VERSION
minikube   Ready    control-plane,master   7m57s   v1.22.2

Now you can go ahead and start deploying your applications to minikube.

#6. Lens

Lens is an open-source desktop application for macOS, Windows, and Linux that allows you to manage your Kubernetes cluster. You can download it for Windows here, and use it to view and manage the state of your Kubernetes clusters. It provides features like managing multiple clusters, support for various Kubernetes distributions, easy debugging, and support for managing Helm Charts, to name a few.

You should see the following screen once the installation is complete. The screenshot also shows that Lens IDE for Kubernetes automatically detected the kubeconfig file and added them to the Lens catalog.

Lens dashboard

In the following screenshot, note that under Catalog > Categories > Clusters, two local Kubernetes clusters are listed:

  • docker-desktop
  • rancher-desktop

Lens IDE figured out this information from the kubeconfig file. Next, you’ll connect to the rancher-desktop Kubernetes cluster.

Lens dashboard clusters

After connecting to the rancher-desktop local Kubernetes cluster, you should see some default pods, deployments, and so on running under Workloads for the kube-system namespace.

Lens dashboard clusters

Another great feature with Lens IDE is that you can install Helm charts with a single click. The Lens IDE will show all charts from configured Helm repositories (Bitnami is configured by default) in the Apps section.

The following screenshot shows NGINX in the search bar.

Lens helm install

To install a chart, simply select it and click Install.

Lens helm install

#Conclusion

The Windows subsystem for Linux helps bridge the gap between Windows and Linux. With tools like Docker Desktop, minikube, kind, and Rancher Desktop, running a Kubernetes cluster locally on Windows can still be a smooth experience.

Remember to also set up tools for managing your Kubernetes cluster, like Lens. With tools like the ones covered in this article, developing and testing Kubernetes applications on Windows shouldn’t be that hard.

Photo by freestocks on Unsplash

Guides
Tools
Comparisons

Do you want early access to great articles like this one?

Thank you for subscribing!
Oops! Something went wrong while submitting the form.

Explore Other Articles