All writing
Updated 3 min readNaren

Your first Kubernetes cluster

Install kubectl, then start a local cluster with Minikube or Kind and check that it answers.

The previous post covered what Kubernetes is and how a cluster is laid out. The quickest way to learn it is to run it, so this post starts a cluster on your own machine with one of two tools, Minikube or Kind.

Both are driven with kubectl, the command-line tool you use to talk to any Kubernetes cluster, so that gets installed first.

What you need

Both Minikube and Kind rely on Docker, or another container runtime or virtualization tool. If you don't have it, install Docker Desktop for your operating system, and make sure it is running before you go on.

Kubernetes also needs a reasonable amount of machine. Aim for at least:

  • 2 CPUs (4 or more is better)
  • 2GB of free memory (4GB or more is better)
  • 20GB of free disk space

Install kubectl

kubectl, pronounced "kube-control" or "kube-cuddle", is the official command-line tool for Kubernetes clusters. You use it for everything from deploying applications to reading logs and managing resources.

On macOS, with Homebrew:

brew install kubectl

On Debian or Ubuntu, from the Kubernetes package repository:

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

On Windows, the easiest routes are Chocolatey or a direct download. The official Kubernetes documentation covers both.

Then check that it installed:

kubectl version --client

Minikube or Kind

There are several tools for running Kubernetes locally. This post covers the two most popular.

Your Laptop Minikube Kind (Kubernetes in Docker) VM Single-Node Kubernetes Cluster Docker Container Control Plane Node Docker Container Worker Node Docker Container Worker Node

Option 1: Minikube

Minikube runs a single-node Kubernetes cluster on your laptop, inside a virtual machine (VM), or natively on Linux. It is a good choice for local development and for learning.

Install Minikube

On macOS, with Homebrew:

brew install minikube

On Linux, by direct download:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube
sudo install minikube /usr/local/bin/

On Windows, with Chocolatey, from PowerShell running as administrator:

choco install minikube

Then check that it installed:

minikube version

Start the cluster

minikube start

Minikube detects the best driver for your system, such as Docker or VirtualBox. To choose one yourself, for example VirtualBox instead of Docker, pass --driver:

minikube start --driver=virtualbox

Either way, Minikube creates a new VM or container and deploys the Kubernetes components into it. The first start can take a few minutes.

Check the cluster

minikube status

List the cluster's nodes. There should be exactly one:

kubectl get nodes

Minikube also ships a web dashboard, which gives you a visual overview of the cluster:

minikube dashboard

The command opens the Kubernetes dashboard in your browser.

Option 2: Kind

Kind, short for Kubernetes IN Docker, runs each Kubernetes node as a Docker container. That makes it light and quick to start. It is especially popular for testing Kubernetes itself and in CI/CD pipelines.

Install Kind

On macOS, with Homebrew:

brew install kind

On Linux, by downloading the pre-built binary:

# For amd64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/kind-linux-amd64
# For arm64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/kind-linux-arm64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

These commands look up the latest stable release of Kind on GitHub, so you always get the current version.

On Windows, with Chocolatey:

choco install kind

Then check that it installed:

kind version

Create a cluster

kind create cluster

This creates a local cluster named kind with a single control-plane node. To give it a name of your own:

kind create cluster --name my-dev-cluster

Kind can also create a multi-node cluster from a configuration file. This one describes a cluster with one control-plane node and two worker nodes:

# kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker

Then create the cluster from it:

kind create cluster --config kind-config.yaml

Talk to the cluster

Kind configures kubectl to use the new cluster automatically. Check that it answers:

kubectl cluster-info --context kind-kind # or kind-my-dev-cluster if you named it
kubectl get nodes

Delete the cluster

When you are done with a Kind cluster, delete it:

kind delete cluster --name kind # or your custom cluster name

You now have a cluster running on your machine and kubectl talking to it. The next post covers the basic building blocks of Kubernetes, Pods and namespaces, and deploys a first application onto this cluster: Pods, YAML and namespaces.