How to launch Minikube on local machine

KubernetesKubernetesBeginner
Practice Now

Introduction

This tutorial provides a comprehensive guide to launching Minikube on your local machine, offering developers a powerful tool for exploring Kubernetes environments. By following this step-by-step approach, you'll gain hands-on experience with Kubernetes cluster deployment, enabling you to develop and test containerized applications in a local, isolated environment.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL kubernetes(("`Kubernetes`")) -.-> kubernetes/BasicCommandsGroup(["`Basic Commands`"]) kubernetes(("`Kubernetes`")) -.-> kubernetes/ConfigurationandVersioningGroup(["`Configuration and Versioning`"]) kubernetes(("`Kubernetes`")) -.-> kubernetes/ClusterInformationGroup(["`Cluster Information`"]) kubernetes(("`Kubernetes`")) -.-> kubernetes/BasicsGroup(["`Basics`"]) kubernetes/BasicCommandsGroup -.-> kubernetes/get("`Get`") kubernetes/ConfigurationandVersioningGroup -.-> kubernetes/config("`Config`") kubernetes/ConfigurationandVersioningGroup -.-> kubernetes/version("`Version`") kubernetes/ClusterInformationGroup -.-> kubernetes/cluster_info("`Cluster Info`") kubernetes/BasicsGroup -.-> kubernetes/initialization("`Initialization`") subgraph Lab Skills kubernetes/get -.-> lab-434716{{"`How to launch Minikube on local machine`"}} kubernetes/config -.-> lab-434716{{"`How to launch Minikube on local machine`"}} kubernetes/version -.-> lab-434716{{"`How to launch Minikube on local machine`"}} kubernetes/cluster_info -.-> lab-434716{{"`How to launch Minikube on local machine`"}} kubernetes/initialization -.-> lab-434716{{"`How to launch Minikube on local machine`"}} end

Minikube Basics

What is Minikube?

Minikube is a lightweight Kubernetes implementation that creates a virtual machine on your local computer and deploys a simple cluster containing a single Kubernetes node. It's designed to make it easy for developers to learn, develop, and test Kubernetes applications without the complexity of setting up a full-scale cluster.

Key Features

Minikube provides several essential features for local Kubernetes development:

Feature Description
Single Node Cluster Creates a local Kubernetes cluster with a single node
Multiple VM Drivers Supports various virtualization platforms like VirtualBox, Docker, and Hyperkit
Kubernetes Version Compatibility Allows testing different Kubernetes versions
Add-on Management Enables easy installation of Kubernetes add-ons

Architecture Overview

graph TD A[Local Machine] --> B[Minikube VM] B --> C[Kubernetes Control Plane] B --> D[Kubernetes Nodes] C --> E[API Server] C --> F[Scheduler] C --> G[Controller Manager]

Use Cases

Minikube is particularly useful for:

  • Local Kubernetes development and testing
  • Learning Kubernetes concepts
  • Experimenting with container deployments
  • Continuous integration and development workflows

System Requirements

Before installing Minikube, ensure your system meets these minimum requirements:

  • 2 CPU cores
  • 2GB RAM
  • 20GB free disk space
  • Internet connection
  • Virtualization support enabled in BIOS

Why Choose Minikube?

Developers and DevOps professionals prefer Minikube because it:

  • Reduces infrastructure complexity
  • Provides a lightweight development environment
  • Supports rapid prototyping and testing
  • Offers a sandbox for learning Kubernetes

At LabEx, we recommend Minikube as an excellent starting point for developers looking to explore Kubernetes technologies and containerization strategies.

Setup Environment

Prerequisites

Before installing Minikube, you'll need to set up the following components:

Requirement Installation Method
Docker Container runtime
kubectl Kubernetes CLI tool
Hypervisor VirtualBox or KVM

Install Docker

## Update package index
sudo apt-get update

## Install dependencies
sudo apt-get install -y ca-certificates curl gnupg lsb-release

## 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

## Set up stable 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 Engine
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

## Add current user to docker group
sudo usermod -aG docker $USER

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"

## Install kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

## Verify installation
kubectl version --client

Install Minikube

## Download Minikube
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

Environment Verification

graph TD A[Install Docker] --> B[Install kubectl] B --> C[Install Minikube] C --> D[Verify Components] D --> E[Ready to Launch Cluster]

System Configuration Check

## Check virtualization support
grep -E --color 'vmx|svm' /proc/cpuinfo

## Verify Docker is running
sudo systemctl status docker

## Check kubectl configuration
kubectl config view
Tool Purpose
kubectx Switch between Kubernetes contexts
helm Kubernetes package manager
k9s Kubernetes CLI dashboard

LabEx Pro Tip

At LabEx, we recommend creating a consistent development environment by using containerization and virtualization tools to ensure smooth Kubernetes learning and development.

First Cluster Launch

Starting Minikube Cluster

## Start Minikube with default configuration
minikube start

## Start Minikube with specific Kubernetes version
minikube start --kubernetes-version=v1.24.0

## Start Minikube with specific driver
minikube start --driver=docker

Cluster Status Verification

## Check cluster status
minikube status

## View cluster information
kubectl cluster-info

## List nodes in the cluster
kubectl get nodes

Cluster Configuration

Command Description
minikube config set memory 4096 Set default memory
minikube config set cpus 2 Set default CPU cores
minikube addons enable metrics-server Enable cluster metrics

Kubernetes Dashboard

## Open Kubernetes dashboard
minikube dashboard

## Access dashboard in background
minikube dashboard --url

Deployment Example

## Create a simple nginx deployment
kubectl create deployment nginx-demo --image=nginx

## Expose deployment as a service
kubectl expose deployment nginx-demo --port=80 --type=NodePort

## List deployments and services
kubectl get deployments
kubectl get services

Cluster Interaction Workflow

graph TD A[Start Minikube] --> B[Verify Cluster Status] B --> C[Create Deployment] C --> D[Expose Service] D --> E[Access Application]

Accessing Applications

## Get service URL
minikube service nginx-demo

## Port forwarding
kubectl port-forward service/nginx-demo 8080:80

Cluster Management Commands

Command Function
minikube pause Pause cluster
minikube unpause Resume cluster
minikube stop Stop cluster
minikube delete Delete cluster

LabEx Recommendation

At LabEx, we suggest practicing different deployment scenarios and exploring Kubernetes features through Minikube to build practical skills.

Troubleshooting

## Check Minikube logs
minikube logs

## Verify system resources
minikube ssh -- df -h
minikube ssh -- free -m

Summary

Successfully launching Minikube opens up a world of Kubernetes development possibilities, allowing developers to experiment with container orchestration, test application deployments, and understand complex Kubernetes concepts without the need for extensive infrastructure. This tutorial has equipped you with the essential skills to create and manage a local Kubernetes cluster, serving as a foundational step in your container orchestration journey.

Other Kubernetes Tutorials you may like