Installing Minikube on macOS

Minikube is an all-in-one solution that comes in a VM and provides all features that a complete Kubernetes cluster provides. In fact, in Kubernetes, you can have a node that has both the master and worker roles, and this is what Minikube is all about.

After installing Minikube, you will have a one node Kubernetes cluster, and this node is a master and a worker at the same time.

In this post, we will go through the steps of installing Minikube on macOS Mojave.

Checking the prerequisites

Before you start Minikube installation, you need to verify some prerequisites your system needs to have. First, you need to make sure that your system can support virtualization. This is because Minikube runs on a virtual machine on top of your physical hardware. The second thing to check is whether a virtualization software like VMware Fusion or Oracle VirtualBox is already installed on your macOS. Finally, you will need to get kubectl installed on your machine to be able to interact with Minikube and manage your Kubernetes environment.

Checking if virtualization is supported on macOS

Run below command, and If you see VMX in the output, it means the VT-x feature is enabled in your machine, so you’re go to go to the next step.

sysctl -a | grep -E --color 'machdep.cpu.features|VMX'

Installing a Hypervisor

In this post, we will use VirtualBox to run Minikube. Simply download Oracle VirtualBox from its official website and follow the instruction to install it on your macOS.

Installing kubectl

Kubectl stands for “Kube Control” and is a command line interface tool used to run commands against Kubernetes clusters.

From a user’s point of view, kubectl is your Swiss army knife to control, manage and administer your Kubernetes clusters, and Minikube is no exception for this. As Minikube runs locally a Kubernetes cluster in your machine, you will need kubectl to be able to talk to it.

To install kubectl, start by downloading the binaries.

curl -LO "https://storage.googleapis.codownloadm/kubernetes-release/release/$(curl -s"

Make the kubectl binary executable and move it into your path

sudo chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl

You may test your kubectl installation with below command.

kubectl version

Installing Minikube

Once you’re done with all above steps, you may start your Minikube installation, by downloading the Minikube stand-alone binary.

curl -Lo minikube

Make the Minikube binary executable and move it to your path

chmod +x minikube && sudo mv minikube /usr/local/bin

Starting Minikube

To confirm whether your Minikube installation is successful, you can run the following command to start up a local Kubernetes cluster.

This will download the Minikube VM boot image and create a virtual machine using VirtualBox to run a local all-in-one Kubernetes cluster VM.

minikube start --vm-driver=virtualbox

Because we are using VirtualBox as a hypervisor to run minikube, the –vm-driver option in above command is virtualbox. If you are using VMware Fusion instead, the –vm-driver would be vmware.

Once minikube start finishes, run the command below to check the status of the cluster.

minikube status

The minikube start command created the all-in-one Kubernetes cluster VM and started it successfully. You may check it out on the VirtualBox console, but you typically don’t interact with this VM directly. Instead, you would use the kubectl command from your macOS terminal for all your Kubernetes management tasks.

Let’s start to use our Minkube cluster and create our first pod, named “frontend” and using the nginx image.

kubectl run frontend --image=nginx

You can check your running pods as below

kubectl get pods

There you have it! We have successfully installed Minikube and run our first pod.

Stopping Minikube

If you want to stop the Minikube VM, simply run below command.

minikube stop

Removing Minikube

If you’re done with your testing and want to get rid of Minikube, run the following command. This will remove the Minikube VM files and free up some spaces on your local machine.

minikube delete

Leave a Comment

Your email address will not be published. Required fields are marked *