Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 78 ยท Getting Started

Running a Local Cluster

Compare kind, minikube, k3d and Docker Desktop Kubernetes, see how managed EKS, GKE and AKS differ, and pick the right cluster for learning and testing.

To learn Kubernetes you need a cluster you can break. You do not have to rent one: several tools run a complete cluster on a laptop, using containers or a small virtual machine. This lesson compares the common choices, shows the commands for each, and gives an overview of the managed services you would use in production.

A cluster cannot run inside this web page, so every command here is read-only: copy it into a terminal on your own machine. The runnable example at the end is a stand-in that helps you choose a tool.

Four ways to run K8s locally

kind Nodes are Docker containers.
minikube One node, many drivers.
k3d k3s in Docker, very fast.
Docker Desktop One checkbox in settings.
1 / 2

What you need first

All local tools need a container engine or a hypervisor, plus the kubectl command-line client (see kubectl Essentials). Most people already have Docker for their images, as described in the Docker tutorial. Check that both tools exist:

Terminal
docker version --format '{{.Server.Version}}'
kubectl version --client

kind: Kubernetes in Docker

kind starts every node of the cluster as a Docker container. It was built for testing Kubernetes itself, which makes it fast, disposable and popular in CI pipelines. A cluster needs only Docker.

Terminal
kind create cluster --name lab
kubectl cluster-info --context kind-lab
kind get clusters
kind delete cluster --name lab

To get several nodes, or to expose ports to your computer, pass a small configuration file:

YAML
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
    extraPortMappings:
      - containerPort: 30080
        hostPort: 8080
  - role: worker
  - role: worker
Terminal
kind create cluster --name lab --config kind.yaml

Because nodes are containers, you can see them with docker ps. Images that you build locally are not automatically visible inside the cluster; load them with kind load docker-image shop-web:1.0 --name lab.

minikube: the all-rounder

minikube creates a single-node cluster (more nodes are possible) using a driver: Docker, a virtual machine such as VirtualBox or Hyper-V, or others. It has the richest set of built-in add-ons, such as an ingress controller and a dashboard.

Terminal
minikube start --driver=docker
minikube status
minikube addons enable ingress
minikube dashboard
minikube stop
minikube delete

minikube stop shuts the cluster down but keeps its state. If you only want to free CPU and memory for a while, minikube pause freezes the Kubernetes components without stopping the cluster, and minikube unpause resumes it where it left off. minikube delete removes everything.

It is a good first choice if you want things to work without writing configuration.

If you cannot install anything, browser-based playgrounds (hosted learning sandboxes that give you a temporary cluster or a few virtual machines to run kubeadm on) let you practice for a short session. They vanish after a time limit and their availability changes, so use them for experiments and keep real work on a local cluster.

k3d: k3s in Docker

k3s is a lightweight, certified Kubernetes distribution from Rancher that fits in a single small binary. k3d runs k3s nodes in Docker containers and starts a cluster in seconds with few resources. It also creates a load balancer container, so mapping a port is a one-liner.

Terminal
k3d cluster create lab --servers 1 --agents 2 -p "8080:80@loadbalancer"
kubectl get nodes
k3d cluster delete lab

Docker Desktop Kubernetes

If you use Docker Desktop on Windows or macOS, open Settings, choose Kubernetes and enable it. After a few minutes kubectl has a new context named docker-desktop. This is the lowest-effort path, but you cannot easily choose the version or add nodes, and it is tied to the desktop application.

Terminal
kubectl config use-context docker-desktop
kubectl get nodes

Managed Kubernetes in the cloud

In production most teams use a managed service, where the provider operates the control plane, patches it and keeps it available. You pay for the worker nodes and usually a small fee for the control plane.

Service Provider Notes
EKS Amazon Web Services Integrates with IAM, load balancers and EBS/EFS storage.
GKE Google Cloud Offers Autopilot mode, where Google also manages the nodes.
AKS Microsoft Azure Integrates with Entra ID and Azure disks and load balancers.

Typical commands to get credentials into your kubeconfig look like this (all read-only here):

Terminal
aws eks update-kubeconfig --name prod --region eu-central-1
gcloud container clusters get-credentials prod --region europe-west3
az aks get-credentials --resource-group rg-prod --name prod

Clusters bill continuously, so delete test clusters when you finish.

Verify the cluster works

Whichever tool you used, run these checks. A healthy local cluster prints nodes with status Ready:

Terminal
kubectl get nodes
kubectl get pods --namespace kube-system
kubectl run hello --image=nginx:alpine --restart=Never
kubectl get pod hello
kubectl delete pod hello

The kube-system namespace holds the cluster's own add-ons (DNS, proxy, network plugin). If those pods are not Running, nothing you deploy will work properly.

Choosing a tool

Which one should you use? It depends on what matters most. The stand-in below encodes a few honest rules of thumb as data and scores each tool against your needs. The scores are the author's judgement, not benchmarks.

Python Pick a local cluster tool

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For a first course like this one, minikube or kind are both fine; use kind when you want multiple nodes, and use the managed service of your cloud when you are ready to run real traffic.

A second small helper shows the other important habit: always know which cluster your terminal is pointing at. The stand-in builds a minimal kubeconfig and prints the active context, a mistake that costs real money in production.

Python Which cluster am I talking to?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Put the current context in your shell prompt, or use a tool that shows it. Many outages begin with a command run against the wrong cluster.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How does kind run the nodes of its cluster?

    kind stands for Kubernetes in Docker; every node is a container, which makes clusters quick to create and delete.
  2. 2. What does a managed service such as EKS, GKE or AKS take care of for you?

    The provider runs and patches the control plane. You still configure workloads and, unless you use an autopilot mode, manage the worker nodes.
  3. 3. Your kubectl commands suddenly act on the wrong cluster. Which setting decides the target?

    kubectl uses the current context from the kubeconfig, which links a cluster address with credentials. Check it with kubectl config current-context.
  4. 4. You built an image locally and your kind cluster cannot find it. What is the usual fix?

    kind nodes have their own image store, so images in your host's Docker are not visible by default.

Summary

  • kind, minikube, k3d and Docker Desktop all give you a throwaway local cluster; kind and k3d are great for multi-node and CI, minikube for add-ons.
  • EKS, GKE and AKS run the control plane for you and bill for worker nodes, so delete test clusters.
  • Verify with kubectl get nodes and the pods in kube-system.
  • The kubeconfig context decides which cluster a command hits; check it before destructive commands.
  • All commands here are read-only; the Python code only models decisions.

Next, learn the tool you will use all day: kubectl Essentials.