DEV Community

Scott Haines
Scott Haines

Posted on

The Basics of Minikube

What is Minikube?

Minikube is a simple to use local virtual environment (and simple shell) that runs a small, dedicated Kubernetes cluster locally on (Mac/Windows/Linux).

photo credit:
Figure 1-1. Minikube Local Environment

Installation instructions are available online, or you can use brew install minikube, if you are running on MacOS.

The Basics

Once installed there are only a small handful of commands needed to operate minikube effectively. The following commands can be run in your terminal of choice.

minikube start

Simply spins up a local single-node Kubernetes cluster and downloads and installs any additional dependencies on your behalf.

minikube start
Enter fullscreen mode Exit fullscreen mode

By default, the minikube virtual machine starts up with 2 (CPU) cores and 2gb of (RAM) memory. There are many options that allow you to customize your installation and specify how the K8s cluster will operate. For example, you can choose the version of K8s, the total memory to allocate to the virtual machine, as well as the number of cpu cores.

Customizing the Minikube Virtual Machine

minikube start \
  --kubernetes-version v1.21.2 \
  --memory 16g \
  --cpus 4 \
  --disk-size 80g
Enter fullscreen mode Exit fullscreen mode

When you are ready to stop working, you can choose to keep the virtual machine running and simply pause the processes within the k8s cluster, or you can choose to fully stop the cluster and reclaim your system resources.

minikube pause

Pause is a novel concept in minikube. Rather than fully shutting down your cluster, you can choose to pause (freeze) specific resources (governed by namespaces) or pause everything that is running. Pausing specific resources for example like local Kafka or Redis can help when you need to see how your applications will act when a service is lost.

Pause all Pods

minikube pause -A
Enter fullscreen mode Exit fullscreen mode

Pause Specific Pods

minikube pause -n kafka,redis
Enter fullscreen mode Exit fullscreen mode

minikube unpause

Any containers paused at a prior point in time can be unpaused.

minikube unpause -n kafka, redis
Enter fullscreen mode Exit fullscreen mode

Using pause and unpause can be a life saver if you have limited local system resources, and as an added benefit provides you with a simple mechanism to return to a specific environment setup, like for example how docker compose is used to spin up specific runtime environments as a slice over Docker. Given Kubernetes maintains the state of the processes running within it, minikube simply snapshots things and frees up your cluster resources (within the virtual machine) when you no longer need to run a specific set of Pods and Containers.

minikube stop

When you decide you want to simply stop everything and shutdown the physical virtual machine just use the stop command.

minikube stop
Enter fullscreen mode Exit fullscreen mode

That concludes the quick tour of the minikube basics. Come back here if you need to revisit any of the basic commands.

Note: minikube delete can be used to clear everything but deleting the underlying virtual machine. Use this with caution since any changes made to the underlying K8s node (minikube node) will be wiped out as well.


Top comments (0)