Set up a multi node Kubernetes cluster locally - using KinD

Local Kubernetes playground using KIND (Kubernetes in Docker)



There are many platforms that offer you kubernetes clusters to play with. For example: Katacoda, Play with Kubernetes, Minkube etc. Or else you can go with GKE(google), EKS(amazon) etc.

But as far as I found, there are limitations with those options. Either these clusters/environments are temporary(Katacoda, Play with Kubernetes etc) or you get only a single node cluster(Minukube) or you will have to pay for what you consume(GKE, EKS etc).

What if, we can set up a highly available kuberenetes cluster locally for our development and testing purposes ? Which is permanent and also it doesn't cost you a single penny. Sounds great ? Furthermore , if the cluster setup process is simple and straight forward ? If you think that is awesome, then this article is for you.

This can be used as a playground for practicing CKA,CKAD and CKS certifications.


1. Install Docker

2. Install kubectl

Follow this documentation to install and setup kubectl.

3. Install Kind

On Linux:

curl -Lo ./kind
chmod +x ./kind
mv ./kind /some-dir-in-your-PATH/kind

On Mac:

brew install kind

3. Add kind to PATH variable

export KIND_PATH=/usr/local/Cellar/kind/0.9.0/bin

4. Create the cluster

  • Cluster name will be ‘kind’
  • Cluster will have only one node (control plane node only)

I want to change the cluster name and also I want to have 1 master node and 2 worker nodes. Lets see how we can achieve that.

4.1 Create kind config file

cat > kind-config.yaml <<EOF
# three node (two workers) cluster config
kind: Cluster
- role: control-plane
- role: worker
- role: worker

4.2 Create cluster

kind create cluster --name k8s-playground --config kind-config.yaml

Now the cluster is ready and you can use kubectl commands to work on the cluster. You can run kubectl commands from your local machine.

kubectl command ran from local machine to list the nodes in the created cluster


Change number of nodes in the cluster.

kind create cluster --name k8s-playground --config kind-config.yaml

SSH into a node

First you need to get the container ids

docker ps
docker ps
docker exec -it c04633be10fd /bin/sh

Setup Kubectl Auto Completion and add alias

And also if you are preparing for any exams like CKA,CKAD and CKS. This will be really helpfull during the exam. Therefore please take sometime to setup auto completion and alias for kubectl depending on your OS.

Im using a MacBook Pro, Steps in the above link didnt work for me for some reason. Then I found and followed the below blog post. It works fine for me.

Delete cluster

kind delete cluster

To delete a specific cluster

kind delete cluster --name k8s-playground