Install minikube on Windows Server 2019 Hyper-V

 If you are looking for a great way to get up to speed with learning Kubernetes, getting your hands in a lab environment is one of the best ways to do that. Kubernetes is arguably not for the faint of heart to deploy correctly and get a working environment. However, there is a way to easily get up and running with a one node Kubernetes “cluster” to get a feel for working with Kubernetes. The solution is called minikube. This post will take a look at how to install minikube on Windows Server 2019 Hyper-V, including configuration, interacting with, and deploying applications. Let’s take a look.

What is minikube?

Minikube is arguably the easiest and quickest way to create a local Kubernetes cluster. It allows doing this on macOS, Linux, and Windows. It is a great tool for both developers as well as those who are new to Kubernetes and want to learn more about the solution, how it works, and how to interact with it. In my opinion it is a great way to get exposed to Kubernetes, so you can then go back and understand what you are building when you want to build everything from scratch. After all, if you don’t understand what the puzzle is supposed to look like in the end, it is hard to build it in the first place.

What are some of the features of the minikube solution?

  • Cross-platform and supports all the major OS’es including Linux, macOS, and Windows
  • You can deploy it as a VM, a container, or on bare-metal depending on what resources you have available
  • It supports many different container runtimes, including Docker, CRI-O, and containerd
  • It supports the latest Kubernetes releases, plus six minor versions
  • Docker installed API endpoint for fast image pushes in the environment
  • You have access to advanced features for further learning such as LoadBalancer, filesystem mounts, and FeatureGates
  • You also have access to Kubernetes application addons
  • Easy to use command line tool
  • Control plane is managed using the minikube tool

Install minikube on Windows Server 2019 Hyper-V

In my home lab, I have many different OS’es to play around with. However, I had just spun up a new Windows Server 2019 server to play around with Docker on Windows and had already installed Hyper-V for Hyper-V isolated containers so this box made a good, quick environment to start playing around with minikube. However, You can create virtual machines of many different varieties for this purpose. You can install minkube on Windows Server 2019 Hyper-V in the following steps:

  1. Check the prerequisites
  2. Use a package manager for minikube
  3. Install minikube
  4. Configure Hyper-V if needed
  5. Start the Kubernetes cluster
  6. Connect to Kubernetes and view the Kubernetes dashboard
  7. Running a Kubernetes application on minikube

1. Check the prerequisites

What are the prerequisites? You will need to have the following in place per the documention to deploy and use the minikube application:

2. Use a package manager for minikube

As mentioned, I already had Windows Server 2019 with the Hyper-V role installed and ready to go. In case you are wondering about the lab environment, I am running the Windows Server 2019 virtual machine on top of a VMware vSphere 7 Update 2 vSAN cluster with hardware CPU instructions exposed to the VM, etc.

There are a couple of different package managers that are supported for installing minikube in Windows. Those are:

  • The new Windows Package Manager
  • Chocolatey

In my case, I wanted to use the Windows Package Manager just to try it out for this purpose, however, it is not supported for Windows Server 2019. Chocolatey is a great package manager for Windows though so for my case, it was the option for Windows Server 2019. Below is a screenshot of installing Chocolatey using the steps provided in the Chocolatey individual walkthrough: https://chocolatey.org/install#individual

Installing chocolatey for installing minikube
Installing chocolatey for installing minikube

3. Install minikube

Once you have the Chocolatey package manager installed, you can easily use it to install minikube. To do that, use the comand:

choco install minikube

You will be prompted to run the script and confirm.

Kicking off the choco install minikube command
Kicking off the choco install minikube command

After confirming the running of the script for installing minikube.

The chocolatey install of minikube is successful
The chocolatey install of minikube is successful

4. Configure Hyper-V if needed

There isn’t really any complicated configuration needed for Hyper-V. However, I wanted to show a couple of things that I ran into with my vanilla Windows Server 2019 Hyper-V server. I hadn’t checked, but I had not configured a default External switch for the server. If you don’t have an external virtual switch configured, you will see the error below, which I ran into.

Minikube startup failure due to a missing hyper v external switch
Minikube startup failure due to a missing hyper v external switch

Below, I just created a simple shared management network External virtual switch.

Creating a new external virtual switch in hyper v
Creating a new external virtual switch in hyper v

The next error I had was related to not having enough memory configured. The Windows Server 2019 Hyper-V host only had 4 GB of memory configured out of my template deployment. So, if you only have 4 GB on Windows Server 2019, you will most likely see the same error I did below – not enough memory in the system to start the virtual machine. So, basically, at this point, I shut down the Hyper-V host and added 4 GB of memory for a total of 8 GB.

Out of memory error when starting minikube
Out of memory error when starting minikube

After I rebooted the Windows Server 2019 server, I tried to run the minikube start command and received the error below. However, as the message details, this is likely due to the failed start from the other attempts. As detailed, run the minikube delete command.

File error starting minikube on windows server 2019
File error starting minikube on windows server 2019

5. Start the Kubernetes cluster

After running minikube delete, I reran the minikube start command once again. The minikube environment built successfully. As you can see below, minikube will select the vm driver to use with the host you have chosen. It is here using the hyperv driver. So, there are no configuration files you have to update manually, etc, which is nice.

Successfully started minikube on windows server 2019
Successfully started minikube on windows server 2019

As you can see below, you can see the minikube virtual machine running in Hyper-V Manager.

Minikube vm provisioned in windows server 2019 hyper v
Minikube vm provisioned in windows server 2019 hyper v

6. Connect to Kubernetes and view the Kubernetes dashboard

Now that you have the minikube environment up and running, you can connect to and interact with the minikube cluster.

kubectl get po -A
Accessing the minikube kubernetes cluster with the kubectl command
Accessing the minikube kubernetes cluster with the kubectl command

To play around with the Kubernetes dashboard, you can run the following command to provision the Kubernetes dashboard:

minikube dashboard
Enabling and viewing the kubernetes dashboard with minikube
Enabling and viewing the kubernetes dashboard with minikube

After running the command to provision the Kubernetes dashboard, minikube will launch the dashboard in a browser for you.

Viewing the minikube kubernetes dashboard
Viewing the minikube kubernetes dashboard

7. Running a Kubernetes application on minikube

To run a simple test application on the Kubernetes cluster provisioned by minikube, you can use the following commands:

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-minikube --type=NodePort --port=8080
kubectl get services hello-minikube
minikube service hello-minikube (this allows minikube to launch browser session for you)
Running kubectl commands to expose application on minikube
Running kubectl commands to expose application on minikube
Launched browser session for kubernetes application running on minikube
Launched browser session for kubernetes application running on minikube

You can easily stop your minikube environment using the minikube stop command.

Stopping the minikube environment
Stopping the minikube environment

Wrapping Up

Minikube is a great way to start getting your hands on Kubernetes technology. The process to Install minikube on Windows Server 2019 Hyper-V is straightforward and only takes just a few minutes to get up and running with a single-node Kubernetes cluster. As shown, there is a ton of functionality with minikube that allows interacting with and using Kubernetes for learning and development.

Check out minikube here: Welcome! | minikube (k8s.io)

Post a Comment

0 Comments