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
- Installing With A Package
- Installing From Release Binaries
- 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
Verify the installation by checking the version.
It will return kind version.
Once you have installed Kind, you can create a cluster using the following command:
kind create cluster --name myfirstk8cluster
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
This 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.
we can see myfirstk8cluster is master node running in the docker container on port 127.0.0.1:54593->6443
Here, we can see cluster info about cluster which we have created.
kubectl get nodes
kubectl get pods -A
All the pods running in
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.
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
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
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
we can see multi-node cluster is created.let's explore the
nodes using below command.
kind get clusters
kubectl get nodes -A
Let's explore the
kubectl get pods -A
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.
Short and sweet, is it possible to create multinode cluster using kind?
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.