Skip to content

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:

  1. 2 CPUs or more
  2. 2GB of free memory
  3. 20GB of free disk space
  4. Internet connection
  5. 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

  1. Insufficient Resources

    # Start with fewer resources
    minikube start --memory=2048mb --cpus=2
    

  2. Docker Permission Issues

    # Add user to docker group and reload
    sudo usermod -aG docker $USER
    newgrp docker
    

  3. 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:

  1. Deploy your first application
  2. Explore the Kubernetes dashboard
  3. Learn about Kubernetes objects
  4. Create your first deployment

Best Practices

  1. Regular Updates

    # Update minikube
    minikube update-check
    

  2. Resource Management

  3. Monitor resource usage
  4. Clean up unused resources
  5. Stop cluster when not in use

  6. Backup

  7. Regularly backup configurations
  8. Document custom settings

Additional Tips

  1. Enable Addons

    # List available addons
    minikube addons list
    
    # Enable specific addon
    minikube addons enable <addon-name>
    

  2. Access Services

    # Create a tunnel to services
    minikube service <service-name>
    

  3. Multiple Clusters

    # Create a second cluster
    minikube start -p cluster2