DEV Community

Deepak Sabhrawal
Deepak Sabhrawal

Posted on

Create Multinode Kubernetes Cluster Using Kind

When it comes to running a Kubernetes cluster on a local system there are multiple options but Kind provides simplicity with a near-to-real Kubernetes cluster experience as we can create a multi-node cluster as well. Minikube 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
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! πŸ‘‹
Enter fullscreen mode Exit fullscreen mode
(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 βœ—)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 πŸ™‚
Enter fullscreen mode Exit fullscreen mode

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.

~/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
Enter fullscreen mode Exit fullscreen mode
~/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
Enter fullscreen mode Exit fullscreen mode

Happy learning...

Top comments (0)