If you’re either working on Kubernetes as part of your job or learning Kubernetes, you will need access to a development / test Kubernetes cluster. Where you can just play without worrying about messing it up.
I have been aware of Minikube for a while because I regularly see it being mentioned in Kubernetes documentation. By the way, if you don’t know, you can use Minikube to quickly stand up your own local single-node Kubernetes cluster on your laptop or desktop.
I decided to try it out as well and document my experience for both myself and you, the reader. So here we go.
Note: Your commands’ outputs might look different.
Minikube Installation
I followed the instructions from this doc: minikube start | minikube (k8s.io)
One of the main requirements for installing Minikube is a Hypervisor or virtual machine manager.
I tried using Docker first, but the installation kept failing. I’ll attach a screenshot of the error at the end of the article.
Install Hyperkit
Then I decided to use Hyperkit, which I installed using the below brew command.
~ % brew install hyperkit
==> Downloading https://ghcr.io/v2/homebrew/core/hyperkit/manifests/0.20200908
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/db4baa34ee2a779e1db4861dd34db8b2fc91786b2b7d32775b5e5de7f47af42a--hyperkit-0.20200908.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/hyperkit/blobs/sha256:26a203b17733ff5166d8c31069e3ecd5af15c74448a51d8b682689cb07e911e8
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/0ba7a770088a60dd6275860b0407ad95191aa6ddde0207b446e17a144b0e7a33--hyperkit--0.20200908.catalina.bottle.tar.gz
==> Pouring hyperkit--0.20200908.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/hyperkit/0.20200908: 5 files, 4.3MB
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/bharathram.manoharan/Library/Caches/Homebrew/yq--4.25.1... (3.0MB)
Removing: /Users/bharathram.manoharan/Library/Logs/Homebrew/oniguruma... (64B)
Removing: /Users/bharathram.manoharan/Library/Logs/Homebrew/jq... (64B)
Install kubectl locally
I prefer installing kubectl on my local machine, even though minikube itself contains kubectl as well, just so I can work with not just this minikube cluster but the other Kubernetes clusters (EKS, My AWS Lab environment etc.)
brew install kubectl
Install Minikube
~ % brew install minikube
==> Downloading https://ghcr.io/v2/homebrew/core/minikube/manifests/1.25.2
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/fa0034afe1330adad087a8b3dc9ac4917982d248b08a4df4cbc52ce01d5eabff--minikube-1.25.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/minikube/blobs/sha256:888a850d809aa5c62c3e3ccb40b059faf52a4519881f08bf93ec1267558b622e
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/bd6123a468a67f63dd664bec951b99b78c45f2eabe18150eeaafb7ddd3ff4827--minikube--1.25.2.monterey.bottle.tar.gz
==> Pouring minikube--1.25.2.monterey.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Summary
🍺 /usr/local/Cellar/minikube/1.25.2: 9 files, 72.3MB
==> Running `brew cleanup minikube`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
(Optional) Set a memory limit for minikube (set a limit according to your system’s capacity)
~ % minikube config set memory 8g
❗ These changes will take effect upon a minikube delete and then a minikube start
Start minikube with Hyperkit as driver
~ % minikube start --driver=hyperkit
😄 minikube v1.25.2 on Darwin 12.4
✨ Using the hyperkit driver based on user configuration
👍 Starting control plane node minikube in cluster minikube
🔥 Creating hyperkit VM (CPUs=2, Memory=8192MB, Disk=20000MB) ...
🐳 Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
▪ kubelet.housekeeping-interval=5m
▪ 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
Verify the minikube installation
~ % kubectl config get-contexts minikube
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* minikube minikube minikube default
~ % kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane,master 11m v1.23.3
Stop minikube when not needed
~ % minikube stop
✋ Stopping node "minikube" ...
🛑 1 node stopped.
Appendix
When I used Docker as the driver of my minikube while starting my cluster, I got the below error.
~ % minikube start --driver=docker
😄 minikube v1.25.2 on Darwin 12.4
✨ Using the docker driver based on user configuration
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
🔥 Creating docker container (CPUs=2, Memory=8192MB) ...
❗ This container is having trouble accessing https://k8s.gcr.io
💡 To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳 Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...- E0604 17:30:28.313962 78446 start.go:126] Unable to get host IP: resolve dns to ip: docker exec -t minikube dig +short host.docker.internal: exit status 9
stdout:
;; connection timed out; no servers could be reached
stderr:
▪ kubelet.housekeeping-interval=5m
▪ 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
Resources:
minikube start | minikube (k8s.io)
Install and Set Up kubectl on macOS | Kubernetes