Skip to content

Instantly share code, notes, and snippets.

@hiranp
Forked from protosam/Minikube for Mac Users.md
Created September 2, 2021 03:29
Show Gist options
  • Save hiranp/05649f26ee3696c7338149b51488e795 to your computer and use it in GitHub Desktop.
Save hiranp/05649f26ee3696c7338149b51488e795 to your computer and use it in GitHub Desktop.
Notes for switching from Docker Desktop to Minikube

With Docker Desktop becoming more restricted, I've decided to move on to just using minikube. In doing so, I've consolidated my notes as follows.

Installation

Use brew to install the docker cli and minikube.

$ brew install minikube docker kubectl hyperkit

Running Minikube

The first time you start minikube, you should specify any settings you desire.

$ minikube start --addons=registry --cni=calico --driver=hyperkit --cpus=8 --memory=8g

When you start with --cni=calico it might take some extra time for the CNI to become active.

$ kubectl -n kube-system wait --for=condition=ready --all pods --timeout=10m

You can check the status with this command if you're unsure if minikube is running or not.

$ minikube status

Anytime you need to start minikube back up, you don't need to set additional flags anymore

$ minikube start

If you need to stop minikube (to free up RAM or CPU), run this command.

$ minikube stop

Resetting Minikube

It doesn't matter if minikube is running or not, you can issue the delete command.

$ minikube delete
🔥  Deleting "minikube" in hyperkit ...
💀  Removed all traces of the "minikube" cluster.

Then just do the start command as mentioned in the Running Minikube section.

Using Docker CLI

Minikube needs to be running and you need to use envirnment variables so that the docker cli tool can contact minikube.

This command does the environment setup for you, after which docker commands should just work.

eval $(minikube docker-env)

If you add this to your ~/.bashrc or ~/.bash_profile, it will automatically setup the docker environment variables for you when minikube is running, in new terminal sessions.

minikube status > /dev/null && eval $(minikube docker-env)

Something important to know, when using --volume and --port it will be applied to the Hyperkit VM, not localhost like with Docker Desktop.

You can get the minikube ip with:

$ minikube ip

As a pro-tip if you need to just curl something, you can do this:

$ docker run -d -p 8000:80 httpd
$ curl http://$(docker ip):8000

Accessing the Minikube VM

When using the hyperkit driver, you can access the VM if necessary.

$ ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip)

Cluster Switching

The drop down menu in Docker Desktop is a very convenient tool for switching between clusters. The same thing can be done with kubectl directly though.

$ kubectl config get-contexts
$ kubectl config use-context CLUSTERNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment