What is kind ?
Kind is a tool for running kubernetes cluster locally using Docker container as nodes.This is best when you do local development. In this blog we will explore Kubernetes with Kind.
- Docker to be installed on the system
How to install Kind on your system ?
To install kind on your system follow the below steps
First run the below step
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-linux-amd64
Second run the below step
chmod +x ./kind
The above command will give an executable permission to the package
At last run the below command to move your executable to the bin folder.
sudo mv ./kind /usr/local/bin
Once the above command is completed check the version like below.
rishivant@rishivant-Vostro-3590:~$ kind --version kind version 0.8.1
So now kind is successfully installed.Lets move further with creating the cluster.
How to create cluster with kind.
To create cluster with kind run the below command.
kind create cluster --name demo-cluster
IN the above command the –name para helps to provide a name else it will take up a default name.
The output of the above is shown below:-
The above output shows the steps that kind took to create a cluster. It created the node , Installed the CNI . Installed the storage class , and finally the clutser with the name got created.
Creating cluster using configuration file .
For this step we will make a yaml file . The file is demorishi.yaml and the syntax is shown below.
kind: Cluster apiVersion: kind.x-k8s.io/v1 name: demorishi.yaml
After writing the above configuration file run the below command to create cluster with configuration file.
kind create cluster –config demorishi.yaml
The above command will also create a cluster with the file.
How to see a cluster.
To see the cluster in your machine type the below command
kind get clusters Output :- rishivant@rishivant-Vostro-3590:~$ kind get clusters demorishi
To get the cluster details type the below command
kubectl cluster-info – -context kind-demorishi
The above output shows info about the cluster. A very inetresting fact is that this cluster is set up in docker container. So on running the command docker ps one can find the container of this node.
Why kind should be considered ?
- kind supports multi-node (including HA) clusters
- kind supports building Kubernetes release builds from source
- support for make / bash or docker, in addition to pre-published builds
- kind supports Linux, macOS and Windows
So till now we learnt about creating cluster with . Now lets learn about creating Local Registry with docker and host that registry in our kind cluster.
Hosting a local registry with Kind and docker.
The steps required to create the above is as follows .
1 – To host a local registry use the below command.
docker run -d --restart=always -p 5000:5000 --name demo-registry registry:2
On running the above command the registry container will start and creates a local registry. Run docker ps to see the running container.
2 – Create a cluster with with the registry endpoint.
To create the cluster create a file with below configuration.
kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 containerdConfigPatches: - |- [plugins.”io.containerd.grpc.v1.cri”.registry.mirrors.”localhost:5000"] endpoint = [“http://demo-registry:5000"] nodes: - role: control-plane
Next run the below command to cretate the cluster with above registry.yaml
kind create cluster --name demo-registry --config registry.yaml
Next lets connect the registry with docker network. Run the below command to do so.
docker network connect kind demo-registry
At last update the cluster about the registry .So for this create a configmap and pas the data into it. For the configmap create a file like config.yaml like below.
apiVersion: v1 kind: ConfigMap metadata: name: demo-registry-hosting namespace: demo data: localRegistryHosting.v1: | host: “localhost:5000”
Next run the command kubectl apply -f config.yaml. Finally the registry is created and is available at the endpoint.
So this was all about how to create cluster with kind and work with it.
To learn more visit the link :- https://blog.knoldus.com/kubernetes-container-orchestration-system-for-devops/