Goglides Dev 🌱

Goglides Dev 🌱 is a community of amazing users

We are working on this space so that IT professionals can grow together.

Create account Log in
Cover image for The process to install and create k8s cluster using Kind in macOS from scratch.
Jeewan Gautam
Jeewan Gautam

Posted on • Updated on

The process to install and create k8s cluster using Kind in macOS from scratch.

In this post, I am going to explain the process of creating a k8s cluster using kind from scratch.

What is kind?

Kind is a tool that helps you run a local Kubernetes cluster using Docker containers. It is easy to install and provides all the features you need to get started with Kubernetes. You can use it to manage your development environment, test out new features, or simply play around with Kubernetes. Kind is also open-source, so you can contribute to its development if you want. Overall, Kind is a great tool for anyone who wants to learn about or use Kubernetes.

Why use kind?

There are many reasons why you might want to use Kind. First, it is easy to install and get started with. There is no need to set up a separate VM or cluster; you can just run it on your local machine. Second, Kind provides all the features you need to get started with Kubernetes. It has support for multiple Kubernetes versions, so you can test out new features or try different configurations. Third, Kind is open-source, so you can contribute to its development if you want. Finally, using Kind is a great way to learn about Kubernetes and how it works.

How to install kind?

Installing Kind is simple. Just follow the instructions on the official website: https://kind.sigs.k8s.io/. You will see various approaches to installation kind

  1. Installing With A Package
  2. Installing From Release Binaries
  3. Installing From Source

Prerequisites: Docker should be available in your system to create a cluster using kind.

Since I am using Macbook Pro, so I will use homebrew to install kind.

brew install kind
Enter fullscreen mode Exit fullscreen mode

Image description

Verify the installation by checking the version.

kind --version
Enter fullscreen mode Exit fullscreen mode

Image descriptionIt will return kind version.
Once you have installed Kind, you can create a cluster using the following command:

kind create cluster --name myfirstk8cluster
Enter fullscreen mode Exit fullscreen mode

Image description
It will create one master myFirstCluster k8s cluster. If you do not specify --name by default kind cluster will be created. keep in mind cluster name is case sensitive.

kind get clusters
Enter fullscreen mode Exit fullscreen mode

Image descriptionThis is the single node cluster we have created just now.

As I mentioned earlier kind is use to create cluster which is running on docker container. Below command is use to see running cluster container.

docker ps
Enter fullscreen mode Exit fullscreen mode

Image descriptionwe can see myfirstk8cluster is master node running in the docker container on port 127.0.0.1:54593->6443

kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

Image descriptionHere, we can see cluster info about cluster which we have created.

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

Image description

kubectl get pods -A
Enter fullscreen mode Exit fullscreen mode

All the pods running in myfirstk8cluster

Image description

As of now, we have created a single node cluster. But using kind we can create multi-node cluster. Let's discuss how we can create multi-node cluster.

First, we need to create a node configuration yaml file and add the resources information in it. To do the same run below command.

vim muli-node-config.yaml
Enter fullscreen mode Exit fullscreen mode

it will create a yaml file called multi-node-config.
After, creating the file add below nodes details to create three master and five worker nodes.

kind: Cluster 
apiVersion: kind.x-k8s.io/v1alpha4
name: demo-mulinode-cluster
nodes:
- role: control-plane
- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
Enter fullscreen mode Exit fullscreen mode

kind represents the type of Kubernetes objects to be created while using the yaml file.
apiVersion represents version of the Kubernetes API you're using to create this object.
name represents name of the cluster
nodes represents The kind: Cluster object has a nodes field containing a list of node objects. If unset this defaults to:

nodes:
# one node hosting a control plane
- role: control-plane
Enter fullscreen mode Exit fullscreen mode

Image description

control-plane is a master node. The API-server and other control plane components will be on the control-plane node.
worker The worker nodes are the part of the Kubernetes clusters which actually execute the containers and applications on them.

we are ready to create 8 nodes cluster with three master and five worker nodes. Now, Run below command in the terminal.

kind create cluster --config  muli-node-config.yaml
Enter fullscreen mode Exit fullscreen mode

Image description
we can see multi-node cluster is created.let's explore the cluster and nodes using below command.

kind get clusters
Enter fullscreen mode Exit fullscreen mode

Image description

kubectl get nodes -A
Enter fullscreen mode Exit fullscreen mode

Image description

Let's explore the pods

kubectl get pods -A
Enter fullscreen mode Exit fullscreen mode

Image description

As of now we have successfully created multi-node cluster using kind.In the next section we will discuss how to create docker image simple Java springboot application and deploy in kubernetes cluster.

Discussion (2)

Collapse
bkpandey profile image
Balkrishna Pandey

Short and sweet, is it possible to create multinode cluster using kind?

Collapse
jeewangautam profile image
Jeewan Gautam Author

Thank you! yes it is possible to create multi-node cluster by creating simple configuration file and we can access it with the help of load balancer. That's the beauty of kind.