How to Install Kubernetes on Mac

This is a step-by-step guide to installing and running Kubernetes on your Mac so that you can develop applications locally.

This is an excerpt from my book, Golden Guide to Certified Kubernetes Application Development. If you’re a web application developer who wants to become a Kubernetes expert very quickly, check out the book.

You will be guided through running and accessing a Kubernetes cluster on your local machine using the following tools:

Installation Guide

The only pre-requisite for this guide is that you have Homebrew installed. Homebrew is a package manager for the Mac. You’ll also need Homebrew Cask, which you can install after Homebrew by running brew tap caskroom/cask in your Terminal.

  1. Install Docker for Mac. Docker is used to create, manage, and run our containers. It lets us construct containers that will run in Kubernetes Pods.

  2. Install VirtualBox for Mac using Homebrew. Run brew cask install virtualbox in your Terminal. VirtualBox lets you run virtual machines on your Mac (like running Windows inside macOS, except for a Kubernetes cluster.)

    Skip to step three if everything has worked to this point.

  3. Install kubectl for Mac. This is the command-line interface that lets you interact with Kuberentes. Run brew install kubectl in your Terminal.

  4. Install Minikube via the Installation > OSX instructions from the latest release. At the time of writing, this meant running the following command in Terminal…

    curl -Lo minikube &&\
          chmod +x minikube &&\
          sudo mv minikube /usr/local/bin/

    Minikube will run a Kubernetes cluster with a single node.

  5. Everything should work! Start your Minikube cluster with minikube start. Then run kubectl api-versions. If you see a list of versions, everything’s working! minikube start might take a few minutes.

Running Minikube on Mac using VirtualBox

Come Together

You’ve installed all these tools and everything looks like it’s working. A quick explanation of how the components relate is needed.