Installing Minikube on Mac OS in Virtualbox

As Kubernetes seems to have "won" the "battle" for container orchestration this post shows how to get up and running with Kubernetes locally via Minikube and Virtualbox on Mac OS.

Although the installation guide is pretty straight forward and well explained, it is a little "scattered" to a few places over the web. So here is a "linear" walkthrough for v0.24.1 on Mac OS with an already installed Virtualbox (which will host the Minikube virtual machine). The setup is pretty much comparable to Docker Toolbox.

Overview / Downloads

Actually all you need to download is

  • kubectl (Kubernetes command-line tool) and
  • Minikube (which runs a single-node Kubernetes cluster inside a VM, e.g. hosted in Virtualbox).

This post assumes that Virtualbox is already installed (as e.g. by previously using Docker Toolbox).

Installing kubectl


If you don't care about checksums you can just download the latest release as mentioned in the first link above:

curl -LO`curl -s`/bin/darwin/amd64/kubectl

# where `curl -s` expands to e.g. `v1.9.2`

Or if you prefer to check the checksum you can download v1.9.2 like so:

curl -LO`

And compare the output of:

shasum -a 256 kubernetes-client-darwin-amd64.tar.gz

with the checksums listed here.

After that you can extract it and cd into it:

tar xvf kubernetes-client-darwin-amd64.tar.gz 
cd kubernetes/client/bin/

Either way make sure that kubectl is executable:

ls -al
chmod +x ./kubectl 	# for the .tar.gz x is already set

After that kubectl needs to be in your path:

sudo mv ./kubectl /usr/local/bin/kubectl

If in the current shell you are neither an administrator or a sudo-privileged user you could also do something like:

mv ./kubectl /Users/Shared
su <admin_user>
sudo mv /Users/Shared/kubectl /usr/local/bin/kubectl
ls -al /usr/local/bin/	# only to check if executable

That's it for the command line tool. However, there are various other ways as well to get kubectl, e.g. Homebrew or Google Cloud SDK.

Installing minikube


Second and last part for the basic setup is to download and run minikube:

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day. Source

curl -Lo minikube

shasum -a 256 minikube

Checksums again can be found here.

Make it executable as well:

chmod +x minikube

And also as before minikube needs to be in your path

sudo mv minikube /usr/local/bin/

Same as above (if not an administrator nor a sudo-privileged user):

mv ./minikube /Users/Shared
su <admin_user>
sudo mv /Users/Shared/minikube /usr/local/bin/minikube
ls -al /usr/local/bin/ # only to check if executable

Getting up and running


If not using virtualbox you need to specify --vm-driver as described here. But if using virtualbox you can just do:

minikube start

The log looked like the following and especially after having downloaded the Minikube ISO it took some time before it continued:

Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Downloading Minikube ISO
# Here it took some time ...
# But you can check the Mac OS Activity Monitor for a "vBox Headless" process or in Virtualbox UI if a new machine "minikube" is running
Getting VM IP address...
Moving files into cluster...
Downloading localkube binary
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

After that your local mini Kubernetes cluster is up and running and you can start your first deployment (most of the the following examples are taken from here):

kubectl run hello-minikube --port=8080

kubectl expose deployment hello-minikube --type=NodePort

You can now interact with your minikube cluster either via cli (minikubeor kubectl) ...

kubectl get pod
curl $(minikube service hello-minikube --url)

minikube service -n default --url hello-minikube  # prints the url
minikube service -n default hello-minikube  # opens a browser window

minikube ip

minikube  # for general usage
minikube service --help	 # for usage of a certain command, here service
minikube service list  # for a list of all services
minikube service -n kube-system list  # for a list of services within the namespace kube-system

kubectl delete service hello-minikube
kubectl delete deployment hello-minikube

minikube stop

... or in the Kubernetes browser-based dashboard:

minikube dashboard
# opens dashboard in browser
# http://<minikube_ip>:30000

Advanced topics can be found here, e.g. debugging, Environment Variables, or Host Folder Mounting.

Have fun with your new docker conductor for your container orchestra.

Further Information