Six tools to Simplify Kubernetes Journey — Day 1 — Kubernetes in Docker(KinD)

kind is a tool for running local Kubernetes clusters using Docker container “nodes”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.

Kind stands for Kubernetes in Docker. It uses Docker container to run Kubernetes nodes.

  • Supports Multi-node
  • HA Control plane
  • You can build and run Kubernetes from source
  • Boots your Kubernetes cluster in ~30sec(Single Node)

Prerequisites

To install kind, you need to meet the following prerequisites.

  • Docker should be up and running
  • Kubectl kind doesn’t require kubectl, but it’s require to perform cluster operations

Installation

  • To download and install kind please follow the below steps
  • Once the kind is installed, you can verify its version using

Create your first Kubernetes cluster

  • The easiest way to create your one node Kubernetes cluster is by executing the below command. Behind the scene, kind will pull the docker image(kindest/node:v1.21.1, This image contain everything Kubelet, Kubeadm, docker, systemd, core images such as etcd, coredns, pause, kube-apiserver etc) to setup the cluster for you.

Kind Architecture(Reference: https://www.youtube.com/watch?v=tT-GiZAr6eQ)

  • Once this done we have kube config ready for us
  • You can verify the image it has downloaded
  • To verify the docker container created by kind
  • By default, kind will switch to the context of the cluster you have created, but if you want to switch to the particular context.
  • kind has created a one node cluster for you.
  • In case if you don’t pass — name argument, kind will create a cluster with default name set to kind.
  • To verify the cluster created by kind
  • To delete the above cluster
  • Now the above cluster is created by fetching the latest image of kind from dockerhub; if you want to install the specific version, give your cluster some specific name pass — name and — image flag.
  • To list all the supported version
  • We have created a one-node cluster(both control-plane(master) and worker in the same node). A multi-node cluster can be created by passing a simple configuration file.
  • The above configuration file will create one control-plane and two worker nodes.
  • To create a cluster using the above configuration, please pass — config to the configuration.
  • As you can see your three node cluster is up and running
  • My favorite feature is that if you want to create a multi-node cluster with multiple control planes (master) and worker nodes, it is easily doable via bind. You need to modify the definition by adding more than one control-plane to the definition.
  • Nothing change on the command end and you need to run the same command
  • As you can see along with multi-node cluster it’s also setup load balancer for you.
  • You can verify load balancer configuration by logging into the container
  • Verify the running processes
  • Check the configuration file

Other Alternatives

I plan to create a separate blog mentioning the pros and cons of using minikube vs K3s vs kind.

Wrapping Up

Kind is super powerful, and in this blog, I barely scratch the surface. If you don’t want to spend hours building Kubernetes cluster or $$$ in building cluster in the cloud, kind is a tool for you.