[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 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 | minikube start |
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 | kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4 |
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 | kubectl create deployment balanced --image=k8s.gcr.io/echoserver:1.4 |
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