Install Minikube on Ubuntu Linux for Easy Kubernetes Development

I’ve long said that Kubernetes is far from user-friendly. Not only is deploying pods and services to a cluster a challenge, but simply getting the cluster up and running can be a real nightmare.
Fortunately, there are a few applications available that make deploying a Kubernetes-friendly environment relatively simple. I’ve already talked about deploying a Kubernetes cluster via MicroK8s and this time around we’ll do something similar with a tool called Minikube. The purpose of Minikube is to create a local Kubernetes cluster for development purposes. This means you won’t be deploying apps and services at scale with this platform. Instead, Minikube is a great way to start learning how to work with Kubernetes.
You can deploy Minikube on Linux, macOS, and Windows. Given Linux is my operating system of choice, I’ll demonstrate on Ubuntu Linux. With this tutorial, you should be able to get a Kubernetes environment up and running in less than five minutes.
Ready? Let’s get busy.
Requirements
To make this work, you’ll need a running instance of a Ubuntu-based Linux distribution and a user with sudo privileges. The minimum requirements of Minikube are:
- Two CPUs or more
- 2GB of free memory
- 20GB of free disk space
With those requirements met, it’s time to install.
Installing Docker CE
Unlike regular Kubernetes, Minikube depends on Docker. So, before Minikube will function, you must first install the Docker runtime. Here’s how.
The first thing to do (after you’ve logged into your Ubuntu instance) is to add the official Docker GPG key with the command:
1 |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg |
Next, add the Docker repository:
1 |
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
Install the necessary dependencies with the following command:
1 |
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y |
Install the latest version of the Docker engine with these two commands:
1 2 |
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io -y |
Finally, add your user to the docker group with the command:
1 |
sudo usermod -aG docker $USER |
Log out and log back in for the changes to take effect.
Docker is now installed.
Installing Minikube
Download the latest Minikube binary with the command:
1 |
wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 |
Copy the file to the /usr/local/bin directory with the command:
1 |
sudo cp minikube-linux-amd64 /usr/local/bin/minikube |
Give the Minikube executable the proper permissions with:
1 |
sudo chmod +x /usr/local/bin/minikube |
Next, we need to install the kubectl command line utility. Download the binary executable file with:
1 |
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl |
Give the new file the executable permission with:
1 |
chmod +x kubectl |
Move the file into /usr/local/bin with the command:
1 |
sudo mv kubectl /usr/local/bin/ |
You can now start Minikube with the command:
1 |
minikube start --driver=docker |
After the command completes, you can verify it’s running properly with the command:
1 |
minikube status |
The output will look like the following:
1 2 3 4 5 6 |
minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured |
Using kubectl via Minikube
With Minikube ready, you can now start to play around with Kubernetes. For example, you can check on the status of the cluster with the command:
1 |
kubetcl get-nodes |
The output of the command will look something like this:
1 2 |
Kubernetes control plane is running at https://192.168.49.2:8443 CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy |
To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump‘
Check the status of the nodes with the command:
1 2 |
NAME STATUS ROLES AGE VERSION minikube Ready control-plane 16m v1.25.3 |
Installing Add-ons
Minkube also includes a number of add-ons to extend the feature set, such as ingress, metrics server, and dashboard. To find out what add-ons are available, issue the command:
1 |
minikube addons list |
Let’s say you want to add the Dashboard add-on, which can be achieved with the command:
1 |
minikube addons enable dashboard |
The output of the command will include the address used to access your new Dashboard. Of course, the caveat to this is that it’ll be a local address, such as 127.0.0.1, and you can’t access it from outside the machine hosting Minikube. Because of this, your best bet is to install and use Minikube on a Linux distribution that has a desktop, otherwise, the Dashboard won’t be accessible.
Other than that, you can start developing or learning the ropes of Kubernetes with the help of Minikube. You certainly won’t be using Minikube in a production environment, but as a development environment, it’s hard to be this simple to use the Kubernetes platform.