Create Multinode Kubernetes Cluster Using Kind
Tags: kubernetes, kind, devops, cloud
Published: 2023-09-17 15:25:35

When it comes to running a Kubernetes cluster on a local system there are multiple options but [Kind](https://kind.sigs.k8s.io/) provides simplicity with a near-to-real Kubernetes cluster experience as we can create a multi-node cluster as well. [Minikube](https://minikube.sigs.k8s.io/docs/) is another super simple option but I found it a little bit resource-heavy and slow in comparison and abstracts to only a single master node cluster. 

To install Kind, follow the instructions [here](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) 
We can use Kind to create a super simple Kubernetes cluster as well which competes Minikube's simplicity. 

`kind create cluster --name demo`

```
(base) ~/code/devops/kubernetes/CKAD (master ✗) kind create cluster --name demo 
Creating cluster "demo" ...
 ✓ Ensuring node image (kindest/node:v1.25.3) 🖼 
 ✓ Preparing nodes 📦  
 ✓ Writing configuration 📜 
 ✓ Starting control-plane 🕹️ 
 ✓ Installing CNI 🔌 
 ✓ Installing StorageClass 💾 
Set kubectl context to "kind-demo"
You can now use your cluster with:

kubectl cluster-info --context kind-demo

Have a nice day! 👋
```

```
(base) ~/code/devops/kubernetes/CKAD (master ✗) kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:53789
CoreDNS is running at https://127.0.0.1:53789/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
(base) ~/code/devops/kubernetes/CKAD (master ✗)
```
Kind uses docker to host the Kubernetes cluster. Check the docker containers

```
(base) ~/code/devops/kubernetes/CKAD (master ✗) docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS                       NAMES
9e4a6223159d   kindest/node:v1.25.3   "/usr/local/bin/entr…"   6 minutes ago   Up 6 minutes   127.0.0.1:53789->6443/tcp   demo-control-plane
```
Now, to create a multi-node cluster we have to use a config file. Save the file content as kind-cluster.yaml

```
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
- role: worker
- role: worker
```
Now create a cluster with following command

`kind create cluster --config kind-cluster.yaml`

```
~/code/devops/kubernetes/CKAD (master ✗) kind create cluster --config kind-cluster.yaml 
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.25.3) 🖼 
 ✓ Preparing nodes 📦 📦 📦  
 ✓ Writing configuration 📜 
 ✓ Starting control-plane 🕹️ 
 ✓ Installing CNI 🔌 
 ✓ Installing StorageClass 💾 
 ✓ Joining worker nodes 🚜 
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
```
you notice, this time cluster name is kind the default one if we do not provide any name. 
You can explore this cluster which has one master node and two worker nodes. You can provide many other configurations as well based on your needs. Check [here](https://kind.sigs.k8s.io/docs/user/configuration/). 

```
~/code/devops/kubernetes/CKAD (master ✗) kubectl get nodes -o wide
NAME                 STATUS   ROLES           AGE     VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
kind-control-plane   Ready    control-plane   5m48s   v1.25.3   172.18.0.4    <none>        Ubuntu 22.04.1 LTS   5.10.124-linuxkit   containerd://1.6.9
kind-worker          Ready    <none>          5m28s   v1.25.3   172.18.0.3    <none>        Ubuntu 22.04.1 LTS   5.10.124-linuxkit   containerd://1.6.9
kind-worker2         Ready    <none>          5m29s   v1.25.3   172.18.0.2    <none>        Ubuntu 22.04.1 LTS   5.10.124-linuxkit   containerd://1.6.9
```

```
~/code/devops/kubernetes/CKAD (master ✗) docker ps 
CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS                       NAMES
32dc5ba3b1b5   kindest/node:v1.25.3   "/usr/local/bin/entr…"   6 minutes ago   Up 6 minutes   127.0.0.1:53879->6443/tcp   kind-control-plane
68b9e9732f8d   kindest/node:v1.25.3   "/usr/local/bin/entr…"   6 minutes ago   Up 6 minutes                               kind-worker2
616c6893f374   kindest/node:v1.25.3   "/usr/local/bin/entr…"   6 minutes ago   Up 6 minutes                               kind-worker
```

Happy learning...