Setting Up Local Kubernetes with Minikube

Install Minikube and kubectl to run Kubernetes locally. Learn essential kubectl commands to interact with your cluster.

7 min read

Setting Up Local Kubernetes with Minikube

In the Previous Tutorial, we learned what Kubernetes is and why it exists. Now it's time for the fun part — let's get Kubernetes running on your laptop!

You don't need a cloud account or a credit card. Minikube runs a full Kubernetes cluster right on your machine. In about 10 minutes, you'll have everything set up and ready to go.

Ready? Let's do this!

What is Minikube?

Wait, why can't I just install Kubernetes directly?

Well, "installing Kubernetes" the real way involves setting up multiple servers, configuring networking, managing certificates... it's a whole production. Minikube is like a cheat code — it creates a mini Kubernetes cluster inside a virtual machine or container on your laptop.

Think of it as a flight simulator. You get the full cockpit experience (the same Kubernetes API that runs in AWS, Google Cloud, or Azure), but you're safely on the ground (your laptop). It's designed for learning and development — not production.

Prerequisites

You need one of these to run Minikube:

  • Docker (recommended) — easiest setup, runs Kubernetes in containers
  • VirtualBox — runs Kubernetes in a VM
  • Hyperkit (macOS) or Hyper-V (Windows) — native hypervisors

This tutorial assumes Docker. If you don't have it, install Docker Desktop.

Install kubectl

How do you talk to a Kubernetes cluster? Through a command-line tool called kubectl.

How do you even pronounce that?

Good question! Some say "cube-control," some say "cube-C-T-L," and some just say "kube-cuttle" like it's a sea creature. Pick your favorite — no one will judge you. (Okay, maybe a little.)

Every interaction with your cluster goes through kubectl. It's your remote control for the cluster.

macOS

brew install kubectl

Linux

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Windows

choco install kubernetes-cli

Or download from kubernetes.io/docs/tasks/tools.

Verify Installation

kubectl version --client

You should see output like:

Client Version: v1.29.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3

If you see a version number, you're golden!

Install Minikube

macOS

brew install minikube

Linux

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Windows

choco install minikube

Or download from minikube.sigs.k8s.io.

Verify Installation

minikube version

Start Your Cluster

Alright, here comes the exciting part — let's fire up your cluster!

minikube start --driver=docker

The first run takes a few minutes because it needs to download the Kubernetes components. Go grab a coffee. You'll see some fun output with emojis like:

😄  minikube v1.32.0 on Darwin 14.0
✨  Using the docker driver based on user configuration
📌  Using Docker Desktop driver with root privileges
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🔥  Creating docker container (CPUs=2, Memory=4000MB) ...
🐳  Preparing Kubernetes v1.28.3 on Docker 24.0.7 ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster

Verify the Cluster

Now let's make sure kubectl can actually talk to your cluster. Think of this as the "hello, are you there?" moment:

kubectl cluster-info

Output:

Kubernetes control plane is running at https://127.0.0.1:55000
CoreDNS is running at https://127.0.0.1:55000/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

Check the node:

kubectl get nodes

Output:

NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   2m    v1.28.3

Boom! You have a running Kubernetes cluster on your laptop. How cool is that?

Essential kubectl Commands

These commands will be your best friends. Seriously, you'll be typing these in your sleep.

Get Resources

List resources of a specific type:

# List all pods
kubectl get pods

# List all services
kubectl get services

# List all deployments
kubectl get deployments

# List everything
kubectl get all

Add -o wide for more details:

kubectl get pods -o wide

Describe Resources

Get detailed information about a specific resource:

kubectl describe pod <pod-name>
kubectl describe node minikube

Create Resources

Create resources from a YAML file:

kubectl apply -f myfile.yaml

Delete Resources

kubectl delete pod <pod-name>
kubectl delete -f myfile.yaml

View Logs

kubectl logs <pod-name>

# Follow logs (like tail -f)
kubectl logs -f <pod-name>

Execute Commands in a Pod

Want to get inside a running container and poke around? You can do that!

# Get a shell inside a pod
kubectl exec -it <pod-name> -- /bin/sh

# Run a single command
kubectl exec <pod-name> -- ls /app

This is super useful for debugging. It's like SSH-ing into a server, but for containers.

Useful Minikube Commands

Here are some handy commands you'll use all the time.

Check Status

"Hey Minikube, are you alive?"

minikube status

Stop the Cluster

Done for the day? Stop the cluster. Don't worry — it keeps all your data:

minikube stop

Start Again

Coming back to work? Just start it up:

minikube start

Delete the Cluster

Messed everything up beyond repair? Nuke it and start fresh:

minikube delete

No judgment. We've all been there.

Access the Dashboard

Minikube comes with a fancy web-based dashboard:

minikube dashboard

This opens a browser with a visual interface for your cluster. It's like task manager but for Kubernetes. Pretty to look at, but honestly, most real work happens in the terminal.

SSH into the Node

Sometimes you need to poke around inside the VM:

minikube ssh

Configure kubectl Context

Here's something neat — kubectl can manage multiple clusters. It uses "contexts" to switch between them.

Wait, why would I have multiple clusters?

Good question! You might have a local Minikube cluster for testing and a production cluster on AWS. Contexts let you switch between them with a single command. Pretty handy, right?

See all contexts:

kubectl config get-contexts

Output:

CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
*         minikube   minikube   minikube   default

The * shows your current context. If you later add other clusters (like a production cluster), you switch between them with:

kubectl config use-context minikube

Allocate More Resources (Optional)

By default, Minikube uses 2 CPUs and 2GB RAM. That's fine for learning, but if you start running multiple apps and things get sluggish, give it more juice:

# Delete existing cluster first
minikube delete

# Start with more resources
minikube start --cpus=4 --memory=8192 --driver=docker

Troubleshooting

Stuff broke? Don't panic. Here are the most common issues and their fixes.

Minikube Won't Start

This is almost always a Docker issue. Make sure Docker is actually running:

# Check Docker is running
docker ps

# If all else fails, the good ol' nuke-and-restart
minikube delete
minikube start --driver=docker

kubectl Can't Connect

"Connection refused" or "unable to connect"? Usually means Minikube isn't running:

# Is it even running, bro?
minikube status

# Update kubectl config
minikube update-context

Out of Disk Space

Docker and Minikube can eat up disk space like nobody's business:

# Clean up Docker (this removes unused stuff)
docker system prune -a

# Nuclear option
minikube delete
minikube start

Quick Reference

CommandDescription
minikube startStart cluster
minikube stopStop cluster
minikube deleteDelete cluster
minikube statusCheck status
minikube dashboardOpen web UI
kubectl get podsList pods
kubectl get allList all resources
kubectl describe <resource>Detailed info
kubectl apply -f file.yamlCreate/update resources
kubectl delete -f file.yamlDelete resources
kubectl logs <pod>View pod logs

What's Next?

Your cluster is up and running — give yourself a pat on the back! In the next tutorial, we'll create your first Pod — the fundamental building block of Kubernetes. You'll deploy an actual nginx web server and see it running in your cluster. Let's go!