Guide to setting up a local Kubernetes cluster on Windows Home to easily test applications.
Containerized applications offer many advantages over traditional deployments, from ease of management to scalability and isolation. Therefore, combining containerized applications with a suitable orchestration engine is the best way to manage modern applications in staging and production environments.
As Windows developers, we need a suitable Kubernetes environment to test our applications. Windows Home handles most computing needs; Windows Pro offers more networking options and is best suited for small and medium-sized businesses that need to manage multiple machines. If you’re a Windows Home user, you can still create the environment needed to configure and use Kubernetes clusters.
This article focuses on setting up a local Kubernetes cluster that allows us to easily test our applications. To do this, we’ll cover
on-premises Kubernetes options How to install minikube How to create a Kubernetes cluster using minikube How to create a multi-node Kubernetes cluster How to mount folders on Kubernetes clusters Local Kubernetes Options There are several
- local Kubernetes
- cluster
- a
options for creating a
in
Windows environment, such as:
- Minikube: This is the most widely used feature-packed tool for deploying local Kubernetes clusters in Windows, Linux, or Mac environments.
- Docker Desktop: Docker Desktop for Windows is the simplest solution that comes bundled with the ability to activate a local Kubernetes cluster.
- kind- This is a tool for creating Kubernetes clusters using docker containers as nodes. The main purpose of this tool is to test Kubernetes, while it can also be used for other purposes such as application deployments, testing, etc.
However, I prefer Minikube over others as it is a standalone solution with many useful features for managing an on-premises Kubernetes cluster.
How to install
Minikube
Minikube relies on a container or VM manager to deploy a Kubernetes cluster. The VM managers it supports are Docker, Hyper kit, Hyper-V, KVM, Parallels, Podman, VirtualBox, and VMWare. Most Windows 10 Pro will use Hyper-V since it’s built in, but since we’re using Windows 10 Home, we’ll need to install a third-party hypervisor. This tutorial will use VirtualBox, but first, let’s install Minikube itself.
For installation, Minikube offers multiple options, such as a simple executable, using the Windows Package Manager or the Chocolatey Package Manager.
You can use any of the above-mentioned options to install Minikube. I will use Windows Package Manager in this tutorial. Run the winget install minikube command from powershell to install Minikube.
Even with Minikube, we need Kubernetes-CLI (kubectl) installed locally to connect and communicate with the Kubernetes cluster. Kubernetes offers two methods for installing kubectl.
Download the kubectl binary and manually add it to
- the Windows path Use a package manager such as Chocolatey or Scoop to install the
- kubectl and automatically add it to the path
- . (Currently, Winget does not support installing kubectl)
Chocolaty kubernetes-CLI installation command
Once the installation is complete, we can verify if it has been installed correctly by checking the kubectl client version. For that, run the following command;
RESULT
You must download and install VirtualBox if you do not already have it installed. Click the link on the download page for Windows hosts under Platform Packages and follow the installation instructions in the installation wizard.
Create a Kubernetes cluster
using Minikube
After installation, we can use the start command to activate a single-node Kubernetes cluster. This will create a Kubernetes cluster with default values. Minikube automatically detects and selects a driver that is installed on your system. You can configure your preferred driver using the -driver flag or set the default driver using minikube config set driver <driver>. You can check the driver configuration options for your preferred driver. In this document, we will use VirtualBox.
Starting Minikube
with custom options
We need to specify custom options to match the Kubernetes cluster with the Windows locale. The most commonly specified options are resource usage and network connectivity.
We explicitly provided the following options in the startup string above when creating the Kubernetes cluster.
- -driver=virtualbox – Apply VirtualBox as the
- driver-cpus=2
- CPU-memory count = 2000m – Limit memory to
- =”20000mb” – Define a disk size of 30GB
– Limit
2GB-disk-size
This will create a single-node Kubernetes cluster with user-configured settings. In addition, you can further customize your Kubernetes cluster using the startup options offered by minikube.
If we look at the Virtual Box manager, we can see that a single instance of minikube has been created.
Verify Kubernetes
cluster configuration
We can simply run the kubectl to get the system pods from the Kubernetes cluster and thus identify a successful configuration.
RESULT
Create a multi-node Kubernetes cluster We can use the -nodes option to create a multi-node cluster if we need to simulate a
Kubernetes
installation Multinode. There, the only consideration is the availability of resources on the local machine.
The above command will create a Kubernetes cluster with three nodes.
We can see that three separate minikube nodes are created in the VirtualBox manager.
With kubectl we can see that all three nodes are present in the cluster
:kubectl get nodes Mounting folders in
the Kubernetes cluster Since we are using a hypervisor (Hyper-V),
Kubernetes
nodes
do not have access to the host machine. Therefore, Minikube provides users with the mount option to assign a host directory to the Kubernetes cluster.
In the example below, we are mounting the C:/data directory on the Kubernetes cluster as /data/user_data/
The above command will prompt users for a message from Windows Firewall to allow access to Minikube through the firewall. Here, you need to allow access, or else the mount will fail. (Grant permissions based on network settings)
In the end, Minikube will report a successful mount. However, this mount is not permanent and the user must keep the PowerShell window open (running process) to keep the mount.
Checking
firewall rules
We can identify the firewall rules created by running the following command via Powershell
.
RESULT
Verifying the mounted directory
To verify mounting, run the minikube ssh command in a PowerShell window. It will establish an ssh connection to minikube. Next, view the list of directories with the ls command.
A successful mount will display the files on the host machine within the minikube directory.
Conclusion
Tools like minikube can be used to simplify local Kubernetes configurations. In addition, developers using Windows Home can use minikube with Windows-based tools and technologies such as Winget, Chocolatey, and Virtual Box to natively support Kubernetes for optimal performance. It also eliminates configuration issues that can arise with third-party tools.
We can easily adapt Kubernetes deployment using custom configurations to meet our exact needs. This ease of use allows us to easily build, test, and deploy containerized applications on Kubernetes.
More
learning
- Join us on Slack
- Sign up for email updates
If you prefer to learn independently and in your own time, you can also check out our learning journey of local development environments. This Kubernetes learning journey walks you through the core concepts and hands-on activities needed to create an effective on-premises development environment with Kubernetes, including everything from code containerization to real-time on-premises testing of distributed services.