Installing Kubernetes (Minikube) on Ubuntu
Minikube is a tool that allows you to run a single-node Kubernetes cluster locally on your computer. It's the perfect solution for developing, testing manifests, and learning Kubernetes without needing a full cloud or physical cluster.
In this guide, we will install Minikube with the Docker driver on Ubuntu 22.04/24.04. This driver is the most stable and performant option for Linux.
System Preparation
Before installation, ensure your system meets the minimum requirements:
- 2+ GB of RAM (4 GB recommended)
- Up to 20 GB of free disk space
- Internet access to download images
1. Update System and Install Base Packages
Open a terminal and run:
sudo apt update && sudo apt upgrade -y
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
2. Install Docker (Minikube Driver)
Minikube uses drivers to create a virtual machine or container. The docker driver runs on top of an already installed Docker.
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker repository
echo "deb [arch=$(dpkg --print-architecture) 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 Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add current user to the docker group (to avoid using sudo)
sudo usermod -aG docker $USER
newgrp docker # Apply group changes without reboot
Verify Docker installation:
docker --version
docker run hello-world # Should print a welcome message
3. Install kubectl
kubectl is the command-line tool for managing Kubernetes clusters.
# Download the latest stable version
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Install the binary
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# Verify installation
kubectl version --client
4. Install Minikube
# Download the latest Minikube version
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# Install
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Verify
minikube version
Starting the Kubernetes Cluster
Now that all dependencies are installed, you can start the cluster.
# Start Minikube with explicit Docker driver
minikube start --driver=docker
What happens when you run the command:
- Minikube downloads the
minikubeimage. - Creates and starts a container (or virtual machine, depending on the driver).
- Sets up
kubelet,apiserver, and other Kubernetes components inside the container. - Copies the
kubeconfigconfiguration to~/.kube/configon your host machine sokubectlcan manage the cluster.
Useful options for minikube start:
--memoryโ RAM allocation (e.g.,--memory=4096).--cpusโ number of CPU cores (e.g.,--cpus=2).--image-mirrorโ image mirror (useful in Russia).
Checking Cluster Status
minikube status
The output should contain host: Running, kubelet: Running, apiserver: Running.
Also verify that kubectl sees the cluster:
kubectl cluster-info
kubectl get nodes # Should show one node with status Ready
Basic Minikube Management Commands
| Command | Description |
|---|---|
minikube stop | Stop the cluster (container/VM stops, data persists). |
minikube start | Start a stopped cluster. |
minikube delete | Delete the cluster and all its data. |
minikube dashboard | Launch the Kubernetes Dashboard web UI (opens in browser). |
minikube ssh | Access the Minikube node's console. |
minikube kubectl -- <command> | Execute a kubectl command inside the cluster (if kubectl is not configured globally). |
Additional Configuration (Optional)
Enabling Built-in Docker Registry
Minikube can start a local Docker registry inside the cluster, so you don't need to push images to Docker Hub.
minikube addons enable registry
After this, images can be tagged as localhost:5000/<image-name> and used in manifests.
Installing Ingress Controller (for HTTP Routing)
minikube addons enable ingress
Troubleshooting Common Issues
- Driver Error:
minikube startfails with a driver-related error. Solution: Ensure the Docker service is running (sudo systemctl status docker). Explicitly specify the driver:minikube start --driver=docker. - Insufficient Resources: Minikube fails to start due to lack of memory/CPU. Solution: Increase limits via
--memoryand--cpusor free up resources on the host machine. - Port Conflict: Port 8443 (API server) or 2379 (etcd) is already in use. Solution: Stop other services using these ports, or start Minikube with
--kubernetes-version=v1.28.0(sometimes helps). kubectldoesn't see the cluster: Afterminikube start,kubectl get nodesreturns an error. Solution: Check theKUBECONFIGvariable. Minikube automatically installs the config at~/.kube/config. Runexport KUBECONFIG=~/.kube/configorminikube update-context.
Conclusion
You have successfully installed and started a local Kubernetes cluster using Minikube on Ubuntu. Now you can:
- Deploy test applications (
kubectl apply -f deployment.yaml). - Try
kubectlcommands (get,describe,logs,exec). - Explore managing configurations, secrets, and PersistentVolumes.
To clean up after your experiments, run minikube delete. To remove all components (Minikube, kubectl, Docker) โ use the apt package manager.
Next Steps: Explore the official Kubernetes tutorials or try deploying a simple application, like Nginx.