Minikube serves as an excellent tool for establishing a local Kubernetes environment to test and experiment with deployments. This guide walks through installation, configuration, and integration with essential tools.
Minikube Installation
Minikube operates through a virtual machine and supports various hypervisor options. VirtualBox is the recommended choice for macOS.
Installation via Homebrew:
$ brew cask install virtualbox minikube
macOS security features may block VirtualBox installation on Mojave and later versions. Access System Preferences > Security & Privacy and approve Oracle software installation on the General tab before rerunning the installation command.
Running and Accessing the Cluster
Start the minikube cluster with:
$ minikube start
Stop the cluster when not in use to conserve battery life:
$ minikube stop
Access the Kubernetes dashboard:
$ minikube dashboard
For users managing multiple cluster contexts, list and switch to minikube:
$ kubectl config get-contexts
$ kubectl config use-context minikube
Ingress Controller
Enable the ingress add-on for deployments requiring ingress resources:
minikube addons enable ingress
Configure local hostnames in /etc/hosts to match ingress rules:
$ echo "$(minikube ip) local.host" | sudo tee -a /etc/hosts
Container Registry
Local Docker Registry
Point your Docker context to minikube:
$ eval $(minikube docker-env)
To revert: $ eval $(docker-machine env -u)
Start a local registry container:
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2
Build and tag images for local registry:
$ docker build . -t <your_tag>
$ docker tag <your_tag> localhost:5000/<your_tag>:<version>
Use localhost:5000/<your_tag>:<version> as the image reference in deployments.
Remote Container Repository
For remote repositories (ECR, GCR, Docker Registry), use the registry-creds addon for authentication:
$ minikube addons configure registry-creds
$ minikube addons enable registry-creds
Note on ECR: If using AWS ECR without a role ARN, provide a placeholder value like “changeme” rather than leaving it blank to prevent deployment failures.
Reference the pull secret in deployments:
imagePullSecrets:
- name: awsecr-cred
Helm
Helm functions as a package manager and configuration tool for Kubernetes. Installation and initialization:
$ brew install kubernetes-helm
$ helm init
Helm currently uses Tiller as its backend, deployed during initialization. Verify deployment with:
$ kubectl describe deploy tiller-deploy --namespace=kube-system
This setup provides a complete local Kubernetes environment for testing deployments before production deployment.