[Kubernetes (K8S) minikube] Use Homebrew (brew) to install minikube Kubernetes (K8S) on macOS

minikube

minikube quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows. We proudly focus on helping application developers and new Kubernetes users.

minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.

All you need is Docker (or similarly compatible) container or a Virtual Machine environment, and Kubernetes is a single command away: minikube start

Highlights

  • Supports the latest Kubernetes release (+6 previous minor versions)

  • Cross-platform (Linux, macOS, Windows)

  • Deploy as a VM, a container, or on bare-metal

  • Multiple container runtimes (CRI-O, containerd, docker)

  • Docker API endpoint for blazing fast image pushes

  • Advanced features such as LoadBalancer, filesystem mounts, and FeatureGates

  • Addons for easily installed Kubernetes applications

Prerequisites

  • Homebrew

    Homebrew is the Missing Package Manager for macOS (or Linux).

    For more information about installing and using Homebrew, see the Homebrew - https://brew.sh/.

    Install Homebrew (brew).

    1
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Installation

Install minikube via Homebrew (brew).

1
% brew install minikube

See minikube start | minikube - https://minikube.sigs.k8s.io/docs/start/ to learn more about installation on other OS platforms.

Usages

Start your cluster

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
% minikube start
๐Ÿ˜„ minikube v1.21.0 on Darwin 11.4
โœจ Automatically selected the docker driver. Other choices: hyperkit, ssh
๐Ÿ‘ Starting control plane node minikube in cluster minikube
๐Ÿšœ Pulling base image ...
๐ŸŽ‰ minikube 1.22.0 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.22.0
๐Ÿ’ก To disable this notice, run: 'minikube config set WantUpdateNotification false'

๐Ÿ’พ Downloading Kubernetes v1.20.7 preload ...
> preloaded-images-k8s-v11-v1...: 492.20 MiB / 492.20 MiB 100.00% 5.86 MiB
> index.docker.io/kicbase/sta...: 359.09 MiB / 359.09 MiB 100.00% 5.28 MiB
โ— minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.23, but successfully downloaded kicbase/stable:v0.0.23 as a fallback image
๐Ÿ”ฅ Creating docker container (CPUs=2, Memory=4000MB) ...
๐Ÿณ Preparing Kubernetes v1.20.7 on Docker 20.10.7 ...
โ–ช Generating certificates and keys ...
โ–ช Booting up control plane ...
โ–ช Configuring RBAC rules ...
๐Ÿ”Ž Verifying Kubernetes components...
โ–ช Using image gcr.io/k8s-minikube/storage-provisioner:v5
๐ŸŒŸ Enabled addons: storage-provisioner, default-storageclass
๐Ÿ„ Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Interact with your cluster

If you already have kubectl installed, you can now use it to access your shiny new cluster:

1
% kubectl get po -A

Alternatively, minikube can download the appropriate version of kubectl, if you donโ€™t mind the double-dashes in the command-line:

1
% minikube kubectl -- get po -A

Initially, some services such as the storage-provisioner, may not yet be in a Running state. This is a normal condition during cluster bring-up, and will resolve itself momentarily. For additional insight into your cluster state, minikube bundles the Kubernetes Dashboard, allowing you to get easily acclimated to your new environment:

1
% minikube dashboard

Deploy applications

Create a sample deployment and expose it on port 8080:

1
2
% kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
% kubectl expose deployment hello-minikube --type=NodePort --port=8080

It may take a moment, but your deployment will soon show up when you run:

1
% kubectl get services hello-minikube

The easiest way to access this service is to let minikube launch a web browser for you:

1
% minikube service hello-minikube

Alternatively, use kubectl to forward the port:

1
% kubectl port-forward service/hello-minikube 7080:8080

Tada! Your application is now available at http://localhost:7080/

LoadBalancer deployments

To access a LoadBalancer deployment, use the โ€œminikube tunnelโ€ command. Here is an example deployment:

1
2
% kubectl create deployment balanced --image=k8s.gcr.io/echoserver:1.4  
% kubectl expose deployment balanced --type=LoadBalancer --port=8080

In another window, start the tunnel to create a routable IP for the โ€˜balancedโ€™ deployment:

1
% minikube tunnel

To find the routable IP, run this command and examine the EXTERNAL-IP column:

1
% kubectl get services balanced

Your deployment is now available at <EXTERNAL-IP>:8080

Manage your cluster

Pause Kubernetes without impacting deployed applications:

1
% minikube pause

Halt the cluster:

1
% minikube stop

Increase the default memory limit (requires a restart):

1
% minikube config set memory 16384

Browse the catalog of easily installed Kubernetes services:

1
% minikube addons list

Create a second cluster running an older Kubernetes release:

1
% minikube start -p aged --kubernetes-version=v1.16.1

Delete all of the minikube clusters:

1
% minikube delete --all

References

[1] Welcome! | minikube - https://minikube.sigs.k8s.io/

[2] Homebrew - https://brew.sh/

[3] Install Tools | Kubernetes - https://kubernetes.io/docs/tasks/tools/

[4] Kubernetes