Photo by Kishan Modi / Unsplash

Quick Installation of Minikube on an Ubuntu Server

Prince Onyeanuna
Prince Onyeanuna

Table of Contents

In a production environment, a Kubernetes cluster usually consists of at least two master and multiple worker nodes. That means you'll need at least five virtual or physical machines for your production cluster. Setting up a full-scale cluster to test new features quickly or learn about new concepts in your local machine is not practical or nearly impossible, especially if your machine doesn't have enough resources like memory and CPU.

To set up a cluster locally, you'll need a lightweight Kubernetes implementation like Minikube. It provides a single-node Kubernetes cluster you can run on your local machine. This means the worker and master nodes will run on the same machine. Installing Minikube is the focus of this article, with the Ubuntu distribution as the target operating system.

Prerequisites

The main prerequisite for installing Minikube is a driver. Minikube supports multiple drivers, but the Docker driver is one of the easiest to install. To install the Docker driver, you need to have Docker installed on your machine. If you don't have Docker installed, you can install it by following the instructions in the official documentation.

You'll also need the following:

  • 20GB of free disk space
  • At least 2 CPUs or more
  • 2GB of free memory

Suppose you're using an Apple M1 chip-based machine and prefer an alternative method to run Minikube without Docker Desktop. In that case, you can follow the instructions provided in this article for specific guidance.

What is Minikube?

Minikube is an open-source command line tool that allows you to run a one-node Kubernetes cluster in a VM on your local machine. It enables you to manage a cluster conveniently without the complexity of setting up a production-grade cluster.

Its primary purpose is to provide an environment that closely resembles a production cluster so you can test your applications locally before deploying them to production. That means if your new feature works in Minikube, it will work in a production cluster.

How does Minikube work?

Although Minikube allows you to deploy a single-node cluster, you can also create a multi-node cluster if you need to. As mentioned in the prerequisites sections, Minikube requires "drivers" to work. The deployment of Minikube depends on the driver you choose. This driver is responsible for creating the environment where the cluster will run.

The driver you choose depends on your operating system. For example, if you're using Windows, you'll use the Hyper-V driver. If you're using macOS, you can use the HyperKit driver. If you're using Linux, you can use the Docker driver. You can check the official Minikube documentation for a complete list of drivers.

You can deploy Minikube inside a Docker container using the Docker driver, a virtual machine using KVM or VirtualBox, or directly on your machine.

Your driver choice depends on the level of isolation and performance you need. For best performance, you'll deploy Minikube directly on your machine. The next best option is to deploy Minikube inside a Docker container. The least performant option is to deploy Minikube inside a virtual machine, which has the upside of having more isolation.

Installing Minikube on Ubuntu

Since this article focuses on installing Minikube on Ubuntu, you can find other installation instructions for different operating systems in the official Minikube documentation.
Installing Minikube is as easy as downloading the binary and installing it.

To install Minikube on Ubuntu, run the commands below:


Download the Minikube binary using the Curl command:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

The above command downloads the latest version of Minikube for Linux.

You should see an output similar to this:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                               Dload  Upload   Total   Spent    Left  Speed
100 89.3M  100 89.3M    0     0  86.2M      0  0:00:01  0:00:01 --:--:-- 86.2M

Install the Minikube binary:

sudo install minikube-linux-amd64 /usr/local/bin/minikube

The above command installs the Minikube binary package in the /usr/local/bin directory.

Remove the downloaded binary:
Although not a steep requirement, you can remove the downloaded binary file.

rm minikube-linux-amd64

Starting Minikube

To start Minikube, run the command below:

minikube start

This command will start Minikube with the default driver, which is Docker. If you want to use a different driver, specify it using the --driver flag. For example, to start Minikube with the KVM driver, you can run the Minikube command below:

minikube start --driver=kvm2

Once Minikube is up, you should get a message similar to this:

Figure 1: Minikube successfully started

Interacting with Minikube

Minikube has several commands you can use to interact with the cluster. Some of the most common commands are:

minikube status

This command shows the status of the Minikube cluster. The output is similar to the one below:

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

minikube tunnel

This command creates a tunnel to the Minikube cluster, which helps expose services running in the cluster to the outside world. The output is similar to the one below:

🏃 Starting tunnel for service default/http-server on port 8080.

minikube delete

This command deletes the Minikube cluster. The output is similar to the one below:

🔥 Deleting "minikube" in Docker...
🔥 Deleting container "minikube" ...
🔥 Removing /home/ubuntu/.minikube/machines/minikube ...
💀 Removed all traces of the "minikube" cluster.

You can check the official Minikube documentation commands section for a complete list of commands.

Common Issues While Installing Minikube

Below are some common issues other developers have ecountered while installing Minikube.

Insufficient Docker privileges

One common issue in this installation process is when Docker needs sudo privileges to run Minikube. You will see the error message ❌ Exiting due to DRV_NOT_HEALTHY when you try to start Minikube.

The entire error message will look like this:

Figure 2: Docker permissions error message

To fix this issue, add your user to the Docker group. You can do this by running the command below:

sudo chown $USER:$USER /var/run/docker.sock

After running this command, start the Minikube cluster again, which should work.

Path not found

Installing Minikube without specifying the path can lead to the command not found error.
You get this error when you try to run any Minikube command:

minikube: command not found

To fix this issue, rerun the installation and specify the path where the Minikube binary should be installed. You can do this by running the command below:

sudo install minikube-linux-amd64 /usr/local/bin/minikube

After running this command, you should be able to run the Minikube command without issues.

Insufficient CPU cores

Another error you can encounter is the ⛔ Exiting due to RSRC_INSUFFICIENT_CORES error. This error occurs when you don't have enough CPU cores to run Minikube.

The entire error message will look like this:

😄 minikube v1.32.0 on Ubuntu 22.04 (xen/amd64)
✨ Automatically selected the docker driver. Other choices: none, ssh

⛔ Exiting due to RSRC_INSUFFICIENT_CORES: has less than 2 CPUs available, but Kubernetes requires at least 2 to be available

Minikube requires at least 2 CPU cores to run. To fix this issue, you must free up some CPU cores on your machine. Once you have freed up enough CPU cores, you can start Minikube again, which should work.

Conclusion

Minikube is a lightweight tool with a very straightforward installation process. You've learnt how to install and start it on your Ubuntu machine.

That's just one step. Now you have your cluster, it's time to start deploying applications for your testing purposes. You must get familiar with the commands and how to interact with the cluster. You can check the official Minikube documentation for more information on how to use Minikube.

Like this article? Sign up for our newsletter below and become one of over 1000 subscribers who stay informed on the latest developments in the world of DevOps. Subscribe now!

MinikubeKubernetes

Prince Onyeanuna Twitter

Prince is a technical writer and DevOps engineer who believes in the power of showing up. He is passionate about helping others learn and grow through writing and coding.