How to Install Minikube in Linux¶
This guide will walk you through installing Minikube on a Linux system, allowing you to run a single-node Kubernetes cluster locally.
Prerequisites¶
Before installing Minikube, ensure your system meets these requirements:
- 2 CPUs or more
- 2GB of free memory
- 20GB of free disk space
- Internet connection
- Container runtime (Docker)
Step-by-Step Installation¶
1. Install Docker (if not already installed)¶
# Update package index
sudo apt-get update
# Install required packages
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# 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=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
# Install Docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Add your user to the docker group
sudo usermod -aG docker $USER
2. Install Minikube¶
# Download the latest Minikube binary
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# Install Minikube
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Verify installation
minikube version
3. Start Minikube¶
# Start Minikube with Docker driver
minikube start --driver=docker
# Verify the status
minikube status
4. Install kubectl¶
# Download kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Make kubectl executable
chmod +x kubectl
# Move kubectl to PATH
sudo mv kubectl /usr/local/bin/
# Verify installation
kubectl version --client
Verify Installation¶
Check if everything is working:
# Check cluster info
kubectl cluster-info
# Check nodes
kubectl get nodes
# Check pods in all namespaces
kubectl get pods --all-namespaces
Common Commands¶
Basic Minikube Commands¶
# Stop cluster
minikube stop
# Start cluster
minikube start
# Delete cluster
minikube delete
# Access dashboard
minikube dashboard
# Get cluster IP
minikube ip
Basic kubectl Commands¶
# Get cluster information
kubectl cluster-info
# List all pods
kubectl get pods
# List all services
kubectl get services
# List all deployments
kubectl get deployments
Troubleshooting¶
Common Issues and Solutions¶
-
Insufficient Resources
# Start with fewer resources minikube start --memory=2048mb --cpus=2
-
Docker Permission Issues
# Add user to docker group and reload sudo usermod -aG docker $USER newgrp docker
-
Network Issues
# Check if minikube can reach the internet minikube ssh ping -c 1 google.com
Checking Logs¶
# View minikube logs
minikube logs
# View specific pod logs
kubectl logs <pod-name>
Next Steps¶
After successfully installing Minikube, you can:
- Deploy your first application
- Explore the Kubernetes dashboard
- Learn about Kubernetes objects
- Create your first deployment
Best Practices¶
-
Regular Updates
# Update minikube minikube update-check
-
Resource Management
- Monitor resource usage
- Clean up unused resources
-
Stop cluster when not in use
-
Backup
- Regularly backup configurations
- Document custom settings
Additional Tips¶
-
Enable Addons
# List available addons minikube addons list # Enable specific addon minikube addons enable <addon-name>
-
Access Services
# Create a tunnel to services minikube service <service-name>
-
Multiple Clusters
# Create a second cluster minikube start -p cluster2