Getting Started with Minikube: A Step-by-Step Guide

Introduction

Minikube is a lightweight Kubernetes implementation that allows you to run a single-node Kubernetes cluster on your local machine. It is perfect for development and testing before deploying applications to a full-scale Kubernetes environment.

What You’ll Learn

  • How to install Minikube on macOS, Windows, and Linux
  • How to start a Minikube cluster
  • Deploying a simple application on Minikube
  • Managing Minikube clusters and persistent storage

Let’s dive in!


1. Installing Minikube

Prerequisites

Before installing Minikube, ensure you have the following:

  • Hypervisor (recommended but optional): Docker, HyperKit, Hyper-V, or VirtualBox.
  • kubectl (Kubernetes CLI): This allows you to interact with Kubernetes clusters.

To install kubectl, run:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/$(uname -s | tr '[:upper:]' '[:lower:]')/$(uname -m)/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Installing Minikube

  • macOS (using Homebrew):brew install minikube
  • Windows (using Chocolatey):choco install minikube
  • Linux (Debian/Ubuntu):curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube

2. Starting Minikube

Run the following command to start Minikube:

minikube start

By default, Minikube selects the best driver (Docker, VirtualBox, etc.), but you can specify a driver manually:

minikube start --driver=docker

To verify that Minikube is running:

minikube status

You should see:

host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

3. Deploying an Application

Creating a Simple Deployment

kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080

Exposing the Deployment

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Checking Running Services

kubectl get services

Accessing the Service

Run:

minikube service hello-minikube

This will open a browser window with the service URL.


4. Managing Minikube

Checking Running Pods

kubectl get pods

Opening Minikube Dashboard

minikube dashboard

This launches a UI to manage Kubernetes resources.

SSH into the Minikube Node

minikube ssh

Deleting the Cluster

minikube delete

5. Persistent Storage with Minikube

Minikube supports persistent volumes. To mount a local directory inside Minikube:

minikube mount /local/path:/mnt/data

This is useful for applications that require shared data.


6. Running Multi-Node (Experimental)

To run a multi-node Minikube cluster:

minikube start --nodes 2

This is helpful for testing distributed workloads.


7. Stopping and Restarting Minikube

  • Stop Minikube without deleting resources: minikube stop
  • Restart Minikube: minikube start

Final Thoughts

Minikube is an excellent tool for testing Kubernetes workloads locally. Whether you’re a beginner or an experienced Kubernetes user, it helps you streamline development and debugging before moving to production.

Scroll to Top