kind (Kubernetes in Docker) 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 uses Docker container to run Kubernetes nodes. It supports creating multiple clusters as opposed to single cluster in Minikube. It also supports multi-node setup which could be very helpful for DevOps trial. It also supports creating a HA based kubernetes ecosystem locally.
Prerequisites
To install kind, you need to have Docker installed and should be up and running.
Installation
- To download and install kind in debian/ubuntu or WSL2 please follow the below steps. Change the version to the desired one.
version=v0.12.0
curl -L "https://kind.sigs.k8s.io/dl/${version}/kind-$(uname)-amd64" -o /usr/local/bin/kind
chmod +x /usr/local/bin/kind
- You can verify the installation using the below command:
kind version
kind v0.12.0 go1.17.8 linux/amd64
- For any other operating system , check the following link : https://kind.sigs.k8s.io/docs/user/quick-start/#installation
Create Kubernetes Cluster with Single Node
- You can create cluster using the command
kind create cluster
In the process, kind will pull the node docker image which contains necessary components like kubelet, kubeadm, docker, systemd and core images such as etcd, coredns, pause, kube-apiserver etc.
export CLUSTER_NAME=cluster-1
~ kind create cluster --name CLUSTER_NAME
Creating cluster "cluster-1" ...
✓ Ensuring node image (kindest/node:v1.23.4) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-cluster-1"
You can now use your cluster with:
kubectl cluster-info --context kind-cluster-1
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
You can create multiple clusters using the above command. If you then want to connect to particular cluster, use the below command
kubectl config use-context kind-$CLUSTER_NAME
You can get the nodes using the kubectl get nodes
command. This will return you a single node.
kubectl get nodes
NAME STATUS ROLES AGE VERSION
cluster-1-control-plane NotReady control-plane,master 18s v1.23.4
Get all the clusters created in kind
kind get clusters
cluster-1
Delete Cluster: kind delete cluster --name $CLUSTER_NAME
kind delete cluster --name cluster-1
Deleting cluster "cluster-1" ...
Create Kubernetes Cluster with multi node
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- 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.
kind create cluster --name $CLUSTER_NAME --config multi-node.yaml
Creating cluster "my-kind-cluster" ...
✓ Ensuring node image (kindest/node:v1.23.4) 🖼
✓ Preparing nodes 📦 📦 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
✓ Joining worker nodes 🚜
Set kubectl context to "kind-cluster-1"
You can now use your cluster with:
kubectl cluster-info --context kind-cluster-1
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
- As you can see your three node cluster is up and running
kubectl get nodes
NAME STATUS ROLES AGE VERSION
cluster-1-control-plane Ready control-plane,master 60s v1.23.4
cluster-1-worker Ready 32s v1.23.4
cluster-1-worker2 Ready 32s v1.23.4
Similarly, if you want multiple control planes, you just need to add subsequent roles in the yaml file as you did for the worker node.
Wrapping Up
Kind is super powerful and could be very helpful if you are a DevOps guy. This could be helpful for developers too if you do not intend to use Docker Desktop or Minikube. If you don’t want to spend hours building Kubernetes cluster in the cloud, kind is a tool for you.
Clap, share, comment, give me feedback. I’d love to hear your thoughts!
Happy Learning.