Minikube Cheat Sheet: most helpful commands and features I wish I knew from the start

Minikube is a tool for running Kubernetes cluster on your local machine. Recently I’ve posted about Minikube’s ugly parts. Now it’s time for the good parts!

Disclaimer

At the time of writing I used Minikube version 1.0.0

$ minikube version
minikube version: v1.0.0

It seems that Minikube is still under active development. So some things may break for your version. You may also want to check every now and then that you are using the latest version available:

$ minikube update-check

Help

Minikube’s online presence is strange. You can find some mentions in Kubernetes Documentation. You can find a bunch of markdown files with Advanced Topics in Minikube’s GitHub repo. And that’s it about documentation. But Minikube’s help is a great source of knowledge. It’s consistently written for every command and subcommand:

$ minikube --help
$ minikube start --help
$ minikube addons configure --help

Minikube Shell Completion

Minikube has a great CLI. But you can’t really enjoy a CLI without shell commands completion. That’s why Minikube supports commands completion for bash and zsh shells. Again, everything you need is in help already:

$ minikube completion --help

Resources

By default you have got 2 CPU, 2048M RAM, 20G disk allocated for your k8s cluster. It’s okay for the most cases. Still you may need to tweak it depending on what are you doing. Use start arguments to get what you want:

$ minikube start --cpus 4 --memory 4096 --vm-driver kvm2

By now you’ve already got used to using --help, haven’t you?

Configuration

If you experiment with your local k8s cluster a lot, deleting it and starting all over with new settings, you may want to make some settings permanent. They are saved under ~/.minikube/config/config.json. You can edit it manually, but CLI provides a better alternative:

# get list of settings
$ minikube config view

# set cpus; changes will take effect upon cluster delete and start
$ minikube config set cpus 4

Services

Your Kubernetes Service that’s provisioned to be available outside of the cluster’s network can be opened in your default browser from the command line:

$ minikube service <your-service-name>

To see the full list of services do:

$ minikube service list

Monitoring

Minikube’s shipped with a bunch of great addons. You can list them, configure, enable, disable and open up:

$ minikube addons list
$ minikube addons --help

The most helpful addons I use daily to look up cluster’s status are dashboard and heapster. Dashboard is a web UI enabled by default. It’s a great tool for monitoring both your pods (Workloads section) and the whole cluster (Cluster section). Fire up you dashboard with:

$ minikube dashboard

Heapster is Grafana-based monitoring tool. Enable and open it with:

$ minikube addons enable heapster
$ minikube addons open heapster

Sign in with admin/admin credentials and go over Pods or Cluster dashboards for super cool statistics charts!

SSH

When working with Persistent Volumes you may need to do some ops on your cluster’s file system. Use secure shell to do it:

# log in `remotely`
$ minikube ssh

# set `docker` user password
> sudo passwd docker
> exit

Now that you have logged in “remotely” you can create directories to mount your Persistent Volume, copy files, etc.:

# copy directory recursively from minikube cluster to the host machine
$ scp -i $(minikube ssh-key) -r docker@$(minikube ip):/mnt/data/ .

Afterword

As with every complex piece of software in active development Minikube’s experience may be frustrating. Still Minikube is a great tool with a bunch of cool features. I wish I’d read an overview like this one when I first launched Minikube. Hope it will help someone.

Comments