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 kubectlOn 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 kubectlOn Windows, the easiest routes are Chocolatey or a direct download. The official Kubernetes documentation covers both.
Then check that it installed:
kubectl version --clientMinikube or Kind
There are several tools for running Kubernetes locally. This post covers the two most popular.
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 minikubeOn 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 minikubeThen check that it installed:
minikube versionStart the cluster
minikube startMinikube 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=virtualboxEither 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 statusList the cluster's nodes. There should be exactly one:
kubectl get nodesMinikube also ships a web dashboard, which gives you a visual overview of the cluster:
minikube dashboardThe 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 kindOn 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/kindThese commands look up the latest stable release of Kind on GitHub, so you always get the current version.
On Windows, with Chocolatey:
choco install kindThen check that it installed:
kind versionCreate a cluster
kind create clusterThis 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-clusterKind 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: workerThen create the cluster from it:
kind create cluster --config kind-config.yamlTalk 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 nodesDelete the cluster
When you are done with a Kind cluster, delete it:
kind delete cluster --name kind # or your custom cluster nameYou 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.