How to Run Kubernetes on Windows

Introduction

Kubernetes is an open-source container orchestration system that automates app deployment and scaling and facilitates resource management. Its main advantage is that it allows users to schedule and run Linux containers in physical or VM clusters.

Although it is primarily a Linux technology, running Kubernetes on Windows is possible.

This tutorial will show you how to run Kubernetes on Windows.

How to run Kubernetes on Windows.

Prerequisites

  • A machine running Windows 10 or 11
  • A user account with administrator privileges
  • A network connection

Installing Kubernetes on Windows

Since Kubernetes is made for Linux, the only way to run it on Windows is in a virtual machine. Follow the steps below to set up a virtual environment for running Kubernetes.

Note: For a fully optimized solution for running Kubernetes clusters, check out our Bare Metal Cloud offering.

Step 1: Enable Hyper-V

Hyper-V is Microsoft's hardware virtualization product that allows the creation of virtual machines in their own isolated space. Hyper-V manages VMs via the default GUI or the CLI.

Note: The requirements for Hyper-V are Windows 10 (Enterprise, Pro, or Education) with at least 4GB of RAM and CPU Virtualization support. If Hyper-V isn't available, check your BIOS settings and ensure virtualization is enabled.

Follow the steps below to enable Hyper-V on Windows:

1. Press the Windows key and search for "Turn Windows features on or off". Select the first result to load the Windows Features window.

Turn Windows features on or off.

2. Check the boxes for Hyper-V and Windows Hypervisor Platform in the feature list.

Enabling the Hyper-V and Windows Hypervisor Platform features.

3. Click OK and wait for the feature installation to finish. When prompted, click Restart now to restart the PC and finish setting up Hyper-V.

Restarting the PC for changes to take effect.

When the PC boots back up, the Hyper-V feature is enabled.

4. Check if Hyper-V is correctly installed. Open Windows PowerShell as an administrator and run the following command:

Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
Checking if Hyper-V is correctly installed.

If Hyper-V is correctly installed, the State section shows as Enabled.

Step 2: Install Docker for Windows

Docker and Kubernetes complement each other. Kubernetes is built on top of Docker and automates tasks such as container creation, deployment, configuration, and resource access.

Follow the steps below to install Docker for Windows:

1. Using a web browser, navigate to the Docker Desktop download page and locate the Download Docker Desktop for Windows section. Click the download link to download the installation package.

Downloading Docker Desktop.

2. Launch the downloaded file to start the Docker installation wizard. The installer prompts you to choose whether to use Hyper-V or WSL 2 and if you want to add a Desktop shortcut. Leave both boxes checked if you have WSL 2 installed and click Ok.

Configuring the Docker Desktop installation.

Note: Follow our instructions to install WSL 2 on Windows. WSL 2 runs on top of Hyper-V, offering the best performance. It features superior memory management and deeply integrates with the rest of the Windows host.

3. Press the Close and log out button to complete the installation.

Finalizing the Docker desktop installation on Windows.

4. Log back into your user account, review the Service Agreement, check the I accept the terms box, and click Accept to complete the Docker installation.

Agreeing to the Docker Service Agreement.

After accepting the agreement, the Docker GUI tool starts.

Docker's first run after installation.

Step 3: Install Kubernetes

Docker comes with a GUI tool that allows users to configure Docker settings and install and enable Kubernetes.

Note: Take a look at the best Kubernetes practices that will help you create stable and efficient clusters.

There are several methods for installing Kubernetes. This article will cover installing Kubernetes via the Docker settings, Minikube, and Kind. Depending on your machine's specifications, choose the method that suits your system:

  • Minikube requires at least 2GB of RAM and 2 CPUs.
  • Kind requires 8GB of RAM to deliver good performance.
  • Installing Kubernetes via Docker settings takes up to 8 GB of RAM.

Before installing Kubernetes, install kubectl, the Kubernetes CLI tool. This utility lets you run commands against Kubernetes clusters.

Follow these steps to install kubectl:

1. Navigate to the official kubectl download page and locate the Install kubectl binary section:

Downloading the latest kubectl release.

2. Click the download link for the latest release. At the time of writing this article, the latest release was 1.24.0. Save the file to a directory such as C:\kubectl.

3. Press the Windows button and search for Environment variables. Select Edit the system environment variables.

Editing the system environment variables.

4. In the System Properties window, click Environment Variables…

Finding the Environment variables option in System Properties.

5. Under the System Variables section, click the Path environment variable and select Edit to add the kubectl system variable:

Editing the Path variable to add kubectl.

6. Click New and add the path to the downloaded kubectl binary file. Select OK in all windows to confirm the changes.

Adding kubectl to the system Path variable.

7. Check if everything is set up correctly by running kubectl in Windows PowerShell:

Running kubectl after installation.

Via Docker GUI

The easiest way to install Kubernetes is by enabling it in Docker settings. Follow the steps below to do so:

1. In the system tray, right-click the Docker icon. Select Settings from the menu.

Opening Docker settings in Windows.

Important: If the Docker icon is missing from the system tray, reboot your system. If the problem persists, check the official troubleshooting guide.

2. In Docker settings, select the Kubernetes tab. Check the Enable Kubernetes box and click Apply & Restart.

Enabling the Kubernetes option in Docker.

3. When prompted, click Install to proceed.

4. The tool downloads the necessary cluster components and creates another VM in the background. When the installation finishes, both the Docker and Kubernetes icons are green, which means they are up and running:

Kubernetes running after enabling it in Docker settings.

Via Minikube

Minikube is an open-source tool for running Kubernetes. It works with Linux, Mac, and Windows by running a single-node cluster inside a virtual machine on the local machine.

Follow the steps below to install Kubernetes via Minikube:

Install Using winget:

1. If you are using winget, the Windows package manager, install Minikube by running:

winget install minikube

The output shows when the installation finishes.

Installing Minikube via Winget.

Install Using the Installer Wizard

1. Download the latest Minikube release and start the executable installer.

2. On the Welcome screen, click Next to proceed.

Minikube installation wizard welcome screen.

3. Read the License Agreement and click I Agree to proceed to the next step.

Agreeing to the Minikube license agreement.

4. Choose a custom install location for Minikube or leave the default one and click Install.

Choosing the install location for Minikube.

5. After the installation completes, click Next and Finish to exit the installer.

Completing the Minikube installation.

After installation, start the Minikube cluster by running the following command:

minikube start

The output shows Done! once the installation finishes.

Starting a Minikube cluster in Windows.

Via Kind (Kubernetes in Docker)

Kind is short for Kubernetes in Docker, which means having Docker installed on your machine is a prerequisite for Kind. Kind works by running Kubernetes as a group of Docker containers without creating a VM. Thus, Kind has a faster startup time compared to Minikube.

Follow the steps below to install Kind:

1. Using a web browser, navigate to the official Kind releases page.

2. Scroll down to the Assets section and click the download link for the Windows version.

Downloading a Kind release.

3. Rename the downloaded file to kind.exe.

4. Move the downloaded file to a directory such as C:\kind, and add the path to the system environment variables. Follow the same steps listed above for adding the kubectl environment variable path.

4. Create a cluster with Kind by running the following command in Windows PowerShell:

kind create cluster
Creating a cluster with Kind.

Step 4: Install Kubernetes Dashboard

The Kubernetes Dashboard is the official web-based UI for managing Kubernetes resources, and it is an alternative to the kubectl CLI tool. However, it needs to be set up manually as it doesn't automatically deploy.

Use the Dashboard to deploy containerized applications to a Kubernetes cluster or manage the cluster resources. You can view a summary of applications running on the cluster and use the options to create or modify individual Kubernetes resources.

Follow the steps below to install the Kubernetes Dashboard:

1. Open Windows PowerShell as an administrator and run the following command to deploy the Kubernetes Dashboard:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml
Deploying the Kubernetes Dashboard on Windows.

2. Create a secure channel for accessing the Dashboard by running:

kubectl proxy
Starting the kubectl proxy for Kubernetes Dashboard access.

3. Access the Dashboard Login page at http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Kubernetes Dashboard login page.

Note: To be able to log in, you need to create a user and have a token. Follow the official guide for creating a sample user and bearer token.

4. After logging in, the Dashboard shows an overview similar to the following image:

An overview of the Kubernetes Dashboard.

How to Uninstall Kubernetes on Windows

Depending on how you installed Kubernetes, there are several methods for uninstalling:

Uninstall From Docker Settings

If you enabled Kubernetes in Docker settings, uncheck the Enable Kubernetes box and click Apply and Reset. The Kubernetes VM is automatically removed.

Uninstall Minikube

If you installed Kubernetes via Minikube, run the following commands to stop and delete the VM:

minikube stop
minikube delete

After that, delete the .minikube and .kube directories from the system.

Uninstall Kind

To uninstall Kind, delete any cluster with the following syntax:

kind delete cluster --name [name]

If you didn't specify a cluster name during creation, run:

kind delete cluster

After deleting created clusters, remove the directory you used to set up Kind.

Conclusion

This tutorial showed how to use the Windows native hypervisors to run Kubernetes. The hypervisors bridge the gap between Windows and Linux, allowing users to run Kubernetes clusters locally on Windows.

Next, we recommend you to read our Kubernetes networking guide or learn the difference between Jenkins and Kubernetes.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Run Kubernetes with Calico
June 23, 2022

Calico is a third-party solution developed to provide flexibility and make Kubernetes network connectivity simpler. It is available on all the major cloud platforms and can also be installed on bare metal. This tutorial will...
Read more
How to Delete a Kubernetes Namespace
May 5, 2022

Namespaces are Kubernetes objects that partition a cluster into virtual clusters. This article will cover the standard procedure for namespace removal and provide an additional method for troubleshooting problems concerning...
Read more
How to Deploy Redis Cluster on Kubernetes
September 30, 2021

Redis is an in-memory data store supporting multiple abstract data structures. Redis Cluster is a set of Redis instances that automatically shards data across nodes. This tutorial shows you how to deploy a Redis Cluster on ...
Read more
Terraform vs Kubernetes: What Are the Differences
July 29, 2021

Automation is one of the most important concepts in software development today. Automating infrastructure speeds up execution of configuration changes, eliminates the human error, and provides the...
Read more
  • © 2022 Copyright phoenixNAP | Global IT Services. All Rights Reserved.