Get started with Minikube

The best way to become familiar with any software application is to get started right away. This is easier said than done with an application as large, powerful and complex as Kubernetes, the software that underpins modern deployments of container-based applications at scale. How can you control Kubernetes without setting up a full hardware cluster?

You can start small with Minikube. Minikube is an incarnation of Kubernetes, fully API-compliant with its big brother edition, but designed to run on local hardware – a developer’s desktop or laptop. It works cross-platform (Linux, Mac, Windows), supports all Kubernetes container runtimes, and can be expanded to add more advanced Kubernetes features.

Please note: This article assumes that you already understand the basics of Kubernetes and have worked with it to some degree. If you are looking for a basic tutorial for Kubernetes, here are some good options.

Minikube requirements

Minikube runs on all three major operating systems (although at this time only on x86-64 hardware) and requires a system with internet connectivity and the following specifications:

  • At least two CPUs (for example, a processor with two or more hardware threads). Hardware-assisted virtualization is not necessary, but it is useful.
  • 2GB of free memory, that is, 2GB of RAM which can save beyond normal system workload requirements.
  • 20 GB of disk space.

You will also need a container or virtual machine manager, which may vary depending on the platform you are running:

  • Any platform that supports Docker can use it as a container system. (You can also use the Docker alternative Podman.)
  • Parallels, VirtualBox, VMware Fusion, or VMware Workstation will also work on any platform that supports them, although these applications come with additional resource overhead and licensing requirements.
  • On macOS, HyperKit is supported.
  • On Windows, you can use Hyper-V.

If you plan to run Minikube on a system that does not have internet access, or only has intermittent access, This is possible, but you may need to set up a local container registry to pull images from.

Minikube installation

Depending on the operating system you are using, you will need to follow different steps to install Minikube.

Linux

The simplest way to install Minikube on Linux is to install its universal binary, which should work on any common distribution:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Mac OS

MacOS users can use an installation method very similar to Linux users:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube

Homebrew users can use brew install minikube.

Windows

On Windows, the following PowerShell script (per Minikube docs) can be used to install Minikube. Make sure to run it as administrator. Note that the directory shown in the script is a temporary installation directory; Minikube does not live in that directory.

The second line of the script ensures that the destination directory is on the system. PATH; you may need to modify the script if you want to change the temporary installation directory.

New-Item -Path 'c:' -Name 'minikube' -ItemType Directory -Force
Invoke-WebRequest -OutFile 'c:minikubeminikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing

$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine)
if ($oldPath.Split(';') -inotcontains 'C:minikube'){ `
  [Environment]::SetEnvironmentVariable('Path', $('{0};C:minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine) `
}

Using virtualization with Minikube

You don’t need to use virtualization to run containers, but it can ease the way. The first step is to make sure that hardware assisted virtualization is enabled in your machine’s BIOS.

Sometimes this option can be difficult to locate. For example, on some systems, such as those using a motherboard built primarily for gaming, the option to control hardware virtualization in the firmware will be in the BIOS section dedicated to overclocking options. Also, the virtualization option may not be visible by default, but only after enabling visibility for expert-level controls.

If you are using virtualization, it is best to use the option in Minikube that is most native to your operating system. On Windows, it would be Hyper-V; on MacOS, HyperKit. On Linux, native containers are ideal, making virtualization completely optional, although you may have your own reasons for using it (for better isolation, for example).

Configure a Minikube controller

Minikube interacts with the container or the hypervisor system of your system through a controller. The available drivers They vary by operating system, but you can use Docker as a safe default on all common platforms.

To configure a controller to use as the default, run the command

minikube config set driver <driver_type>

where <driver_type> it is one of the possible options. These are the most common (and should be self-explanatory):

Other drivers are available depending on the platform and installed software:

  • virtualbox – Uses VirtualBox as VM provider. This is a useful option in Windows if you can’t use Hyper-V (for example, if you are running Windows Home). Note that Minikube will not install VirtualBox; you need to configure it yourself.
  • podman – A container alternate runtime to Docker which uses a daemon-free architecture and does not require root privileges. Please note that this driver is still considered experimental and should not be used in production.
  • vmware – Driver for all VMware-based hypervisors. (Installation of the actual VMware software is your responsibility.)
  • hyperkit – Driver for the open source hypervisor for MacOS. This is installed with Docker Desktop, so if you are already using Docker, you may not need to use it.
  • parallels – Driver for Parallels Desktop for Mac, which does not require VT-x hardware support.
  • ssh – Allows you to run in a virtual machine provided by the user over ssh. Please note that when you run minkube start, you need to pass the address of the virtual machine with a command line switch, for example, --ssh-ip-address=vm.machine.com.
  • none – Use a bare metal controller, usually on Linux. For advanced or experimental use only.

You can also provide a controller by using a command line switch whenever you start Minikube:

minikube start --driver=docker

This is useful if you need to temporarily switch drivers to test something. However, for the most part, you’ll want to set up a controller to use full time as part of your standard workflow.

Starting Minikube

Once you have installed Minikube and configured your default driver, you can start the cluster by typing minikube start. The startup process can take a little time, as the Minikube may need to obtain images and configure them.

You can then use kubectl work with Minikube as you would with Kubernetes.

Note that instead of typing kubectl only you you may need to prefix it with minikube and use the -- change to pass the parameters. For example, instead of kubectl create deployment (plus other options for an implementation), you need to write minikube kubectl -- create deployment.

Minikube tries to stay up-to-date with the latest version of Kubernetes. If you need to work with an older version, you can do so by specifying a version with the start command:

minikube start --kubernetes-version=v1.16.0

Minikube panel

Minikube comes with a web-based dashboard that provides a total view of the cluster: workloads, services, configuration information, cluster data, custom resource definitions, and much more.

To open the panel in the default browser, just type minikube dashboard on the command line. Note that if you close the command session in which you started the panel, the panel will be closed automatically, unless you start the panel as a separate process.

minikube board IDG

The Minikube dashboard provides an all-in-one interactive view for your desktop’s Kubernetes configuration.

Use Minikube instead of Docker Desktop

Due to changes in Docker Desktop licensing and costs, many developers are exploring alternatives. Minikube can function as a fair replacement for Docker Desktop without too much additional work. That’s how:

  1. If you already have Docker Desktop installed, remove it and restart.
  2. Check that you have the environment variable. DOCKER_BUILDKIT adjusted to 1. (This allows BuildKit for better performance during the construction process).
  3. Install the Docker CLI – no Docker Desktop or the Docker daemon, just the command line tool. One way to do this is with a package manager, for example, using Chocolatey on Windows.
  4. Start Minikube normally. If you want to create Docker images, you must use the Docker driver; if you just want to run containers, you can use a hypervisor or a virtual machine.
  5. If you don’t plan on using Kubernetes (just run containers as-is without orchestration features), you can use minikube start --no-kubernetes as the command to start Minikube.
  6. To run minikube docker-env (You may need to do this as an administrator) to generate a list of instructions required to configure Docker to use Minikube as its runtime host. These instructions vary by operating system.
  7. After following those instructions, the docker The command line tool must use Minikube as its host. You can verify this by typing docker ps and see if you get a list of running containers.

Note that you will need to invoke the commands described by Minkube in step 6 to every command session where you want to use Docker.

Copyright © 2021 IDG Communications, Inc.

Leave a Comment