Introduction
If you’re a DevOps engineer or Kubernetes enthusiast, installing Minikube on your Ubuntu machine is a great way to simulate a Kubernetes cluster locally. Minikube lets you run a single-node Kubernetes cluster on your laptop or virtual machine for development and testing purposes.
In this comprehensive guide, we’ll walk you through installing Minikube on Ubuntu using a simple Bash script, covering all necessary steps, including kubectl
installation and Docker setup.
Why Use Minikube?
Minikube is the ideal choice for local Kubernetes development due to its simplicity and ease of use. Here are a few reasons why developers and DevOps professionals prefer Minikube:
- Lightweight and fast
- Easy to install and manage
- Compatible with multiple drivers like Docker, VirtualBox, and KVM
- Great for testing CI/CD pipelines and Kubernetes configs
Prerequisites
Before we get started, ensure the following:
- You are using Ubuntu 20.04+
- You have sudo/root access
- Docker is installed (Minikube will use Docker as the driver)
If Docker is not installed, you can install it using:
sudo apt update
sudo apt install -y docker.io
sudo systemctl enable docker --now
Step-by-Step Bash Script to Install Minikube on Ubuntu
You can use the following Bash script to install Minikube and kubectl
, set up Docker permissions, and start your Minikube cluster.
#!/bin/bash
# Check if the script is being run with root/sudo privileges
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root or with sudo. Aborting..."
exit 1
fi
# Update system packages
apt update
# Install required packages
apt install -y curl
# Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube
mv minikube /usr/local/bin/
# Install kubectl
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x kubectl
mv kubectl /usr/local/bin/
# Start Minikube
su ubuntu -c "minikube start --apiserver-ips 192.68.1.45 --driver=docker"
# Add user to Docker group (optional - to avoid using sudo)
usermod -aG docker $SUDO_USER
echo "Minikube installed successfully."
Save this script:
Save the script as install_minikube.sh
and run it with:
sudo bash install_minikube.sh
Verifying the Installation
After the installation completes, you can verify that Minikube and Kubernetes are working properly:
kubectl get nodes
You should see an output showing a single Minikube node in the Ready
state.
Tips for Using Minikube
- To stop your Minikube cluster:
minikube stop
- To delete your Minikube cluster:
minikube delete
- To open Minikube dashboard:
minikube dashboard
Common Issues and Troubleshooting
- Docker permission errors: Make sure your user is added to the Docker group and restart the shell.
- Minikube not starting: Verify Docker is installed and running. Also check your system’s virtualization support.
- kubectl not found: Ensure
/usr/local/bin
is in your system’s$PATH
.
Final Thoughts
Minikube is an excellent way to get hands-on with Kubernetes locally. Whether you’re learning K8s concepts or testing complex deployments, having Minikube running on Ubuntu gives you a powerful edge. With the provided script, you can save time and reduce setup friction.
For DevOps engineers, automating this installation as part of your dotfiles or team onboarding process can bring consistency and speed.
Follow me on Linkedin
FAQ
Q: Can I use VirtualBox instead of Docker as a driver?
Yes, Minikube supports multiple drivers. Just install VirtualBox and start Minikube with:
minikube start --driver=virtualbox
Q: Can I run Minikube on a cloud VM?
Yes, but performance and compatibility may vary. Ensure nested virtualization is enabled.
Q: Is Minikube production-ready?
No, Minikube is only meant for local development and testing.