Setting Up Kubernetes with Kind: Quick and Easy Installation Guide

Shrihari Haridas
4 min readSep 27, 2024

--

  • Kind is a tool for running local Kubernetes clusters using Docker container “nodes.”
  • It was primarily designed for testing Kubernetes itself but can also be used for local development or continuous integration (CI).
  • If you have Go 1.16+ and Docker, Podman, or Nerdctl installed, simply run:

go install sigs.k8s.io/kind@v0.24.0 && kind create cluster

  • That’s all you need!

Introduction

In today’s fast-paced development environment, having a local Kubernetes setup is essential for testing and deploying applications efficiently. Kind (Kubernetes in Docker) simplifies this process by allowing developers to create Kubernetes clusters using Docker containers. Whether you’re a beginner looking to learn about Kubernetes or an experienced developer needing a lightweight solution for testing, Kind provides a user-friendly way to spin up clusters quickly. In this blog, we will guide you through the installation of Kind, the creation of single-node and multi-node clusters, and how to manage these clusters effectively.

  1. I deployed a t2.medium instance on AWS, but you can choose a server based on your requirements. Just make sure it’s easy to use and supports Docker installation.
  2. So, let’s install Kind!
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/

3. Now that we have installed Kind, we need to create a cluster. Run the following command:

 kind create cluster --image kindest/node:v1.29.8@sha256:d46b7aa29567e93b27f7531d258c372e829d7224b25e3fc6ffdefed12476d3aa --name cka-cluster1

Here, --image specifies the Kind image that you want to use. You can find the available images at Kind Releases and copy the image ID as needed.

Next, --name is where we specify the name for the cluster, which can be anything you choose. After that, run the command.

4. Then, install the kubectl utility.

snap install kubectl --classic

5. Now you can manage your cluster as well. If you want to see the cluster information, run the command below:

kubectl cluster-info --context kind-cka-cluster1

6. You can then interact with your cluster using Kubernetes commands (it’s a single-node cluster).

kubectl get nodes

7. As I mentioned, it’s a single-node cluster with a control plane. Now, let’s create a multi-node cluster. For that, copy the file below and save it as config.yaml.

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker

Then, re-run step 3 with the additional argument to pass the config file and change the cluster name.

kind create cluster --image kindest/node:v1.29.8@sha256:d46b7aa29567e93b27f7531d258c372e829d7224b25e3fc6ffdefed12476d3aa --name cka-cluster2 --config config.yaml

8. Now that we have two clusters, you can see or switch between them. To do this, run the command below, where an asterisk (*) indicates the current cluster.

 kubectl config get-contexts

to switch to cluster 1

kubectl config use-context kind-cka-cluster1 # to switch between 2 cluster or context
kubectl config get-contexts
kubectl get nodes

Conclusion

In conclusion, Kind is an invaluable tool for developers and teams looking to harness the power of Kubernetes locally. By following the steps outlined in this blog, you can easily install Kind, create both single-node and multi-node clusters, and manage them with simple commands. This setup not only enhances your understanding of Kubernetes but also allows for efficient testing and development workflows. As you explore Kubernetes further, you’ll find that Kind serves as a robust foundation for building and deploying containerized applications in a cloud-native environment. Happy clustering!

--

--

Shrihari Haridas
Shrihari Haridas

Written by Shrihari Haridas

Hello everyone, I am Shrihari Haridas I am a Cloud & DevOps Engineer, I work with most of DevOps Tools like, Jenkins, Git, Docker, etc.!& for Cloud AWS

No responses yet