KinD allows you to run a multi-node Kubernetes cluster on a single server that runs Docker. We understand that a multi-node Kubernetes cluster requires multiple machines, but how can we run a multi-node Kubernetes cluster on a single server? The answer is simple: KinD uses a Docker container as a Kubernetes node. So, if we need a four-node Kubernetes cluster, KinD will spin up four containers that behave like four Kubernetes nodes. It is as simple as that.

While you need Docker to run KinD, KinD internally uses containerd as a container runtime instead of Docker. Containerd implements the container runtime interface; therefore, Kubernetes does not require any specialized components, such as dockershim, to interact with it. This means that KinD still works with Kubernetes since Docker isn’t supported anymore as a Kubernetes container runtime.

As KinD supports a multi-node Kubernetes cluster, you can use it for your development activities and also in your CI/CD pipelines. In fact, KinD redefines CI/CD pipelines as you don’t require a static Kubernetes environment to test your build. KinD is swift to boot up, which means you can integrate the bootstrapping of the KinD cluster, run and test your container builds within the cluster, and then destroy it all within your CI/CD pipeline. This gives development teams immense power and speed.

Important

Never use KinD in production. Docker in Docker implementations are not very secure; therefore, KinD clusters should not exist beyond your dev environments and CI/CD pipelines.

Bootstrapping KinD is just a few commands away. First, we need to download KinD, make it executable, and then move it to the default PATH directory using the following commands:

$ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 $ chmod +x kind

$ sudo mv kind /usr/local/bin/

To check whether KinD is installed, we can run the following command:

$ kind version

kind v0.20.0 go1.20.4 linux/amd64

Now, let’s bootstrap a multi-node KinD cluster. First, we need to create a KinD config file. The KinD config file is a simple YAML file where you can declare what configuration you want for each node. If we need to bootstrap a single control plane and three worker node clusters, we can add the following configuration:

$ vim kind-config.yaml

kind: Cluster

apiVersion: kind.x-k8s.io/v1alpha4

nodes:

  • role: control-plane
  • role: worker
  • role: worker
  • role: worker

You can also have an HA configuration with multiple control planes using multiple node items with the control plane role. For now, let’s stick with a single control plane, three-worker node configuration.

To bootstrap your KinD cluster with the preceding configuration, run the following command:

$ kind create cluster –config kind-config.yaml

With that, our KinD cluster is up and running. Now, let’s list the nodes to see for certain by using the following command:

$ kubectl get nodes    
NAMESTATUSROLESAGEVERSION
kind-control-planeReadycontrol-plane72sv1.27.3
kind-workerReady<none>47sv1.27.3
kind-worker2Ready<none>47sv1.27.3
kind-worker3Ready<none>47sv1.27.3

Here, we can see four nodes in the cluster – one control plane and three workers. Now that the cluster is ready, we’ll dive deep into Kubernetes and look at some of the most frequently used Kubernetes resources in the next section.

Leave a Reply

Your email address will not be published. Required fields are marked *