Jane interface
Kind is another Kubernetes SIG project, but it is very different from Minikube. It can migrate clusters to Docker containers, which is much faster to start than generating virtual machines. In short, Kind is a tool that uses Docker container nodes to run local Kubernetes clusters (CLI).
Next, let’s get started!
preparation
To successfully complete this tutorial, you need to have the following programs ready on your local system:
-
Go
-
Docker service to run
Ann is installed
Use the following command to download and install the KIND binaries:
GO111MODULE = "on" go get sigs. K8s. IO/[email protected]Copy the code
Make sure the KIND binary exists
> kind version
kind v0.8.1 go1.14.2 darwin/amd64
Copy the code
We should now be able to start a Kubernetes cluster using kind CLI:
Usage:
kind [command]Available Commands:
build Build one of [node-image]
completion Output shell completion code for the specified shell
create Creates one of [cluster]
delete Deletes one of [cluster]
export Exports one of [kubeconfig, logs]
get Gets one of [clusters, nodes, kubeconfig]
help Help about any command
load Loads images into nodes
version Prints the kind CLI version
Copy the code
In this article, we will focus on the create, get, and DELETE commands.
Creating a cluster
To create a cluster, run the following command:
kind create cluster
> kind create cluster Creating cluster "kind" ... â Ensuring node image (Kindest /node:v1.18.2) đŧ Preparing nodes đĻ â Writing configuration đ â Starting control-plane đšī¸ â Installing CNI đ â Installing StorageClass đž Set kubectl context to "kind-kind" You can now use your cluster with:kubectl cluster-info --context kind-kind Have a nice day! đCopy the code
A Kubernetes cluster will be created by pulling the latest Kubernetes node (V 1.18.2). We have just created a Kubernetes cluster with v 1.18.2.
If we do not have the –name parameter during cluster creation, the cluster name will be set to KIND by default.
Create a K8S cluster for a specific version
We can deploy a particular version of the Kubernetes cluster by passing the –image parameter.
The following command is used:
Kind create cluster --image Kindest /node:v1.15.6
Creating cluster "kind" ... â Ensuring node image (Kindest /node:v1.15.6) đŧ Preparing nodes đĻ â Writing configuration đ â Starting control-plane đšī¸ â Installing CNI đ â Installing StorageClass đž Set kubectl context to "kind-kind" You can now use your cluster with:kubectl cluster-info --context kind-kind Have a nice day! đCopy the code
Lists the deployed clusters
Enter the command kind get Clusters
> kind get clusters
kind
kind-1.15.6
Copy the code
This should list the two clusters we created earlier with different VERSIONS of K8S.
Set the context for Kubectl
After the cluster is created, Kubectl points to the recently created K8S cluster.
Let’s examine all the available contexts.
> kubectl config get-context CURRENT NAME CLUSTER kind-kind kind-1.15.6 kind-kind-1.15.6Copy the code
From the output, we can conclude that the Kubectl context is currently set to the latest cluster, kind-1.15.6. (Context names are prefixed with kind)
To set the kubectl context to a KIND cluster with version 1.18.2, we need to do the following:
> kubectl config set-context kind-kind
Context "kind-kind" modified.
Copy the code
To verify that Kubectl points to the correct cluster, we need to check the nodes:
> kubectl get nodes
NAME STATUS ROLES AGE VERSION
kind-1.18.2-control-plane Ready master 8m20s v1.18.2
Copy the code
Deleting a Cluster
To delete a particular cluster, you can pass the cluster name to the delete command in the –name parameter.
Run the kind delete cluster –name kind command
> kind delete cluster --name kind
Deleting cluster "kind" ...
Copy the code
Deleting all Clusters
If you want to delete all clusters at once, run:
Kind delete clusters - all
> kind delete clusters --all
Deleted clusters: ["kind-1.15.6"]
Copy the code
What’s kind’s advantage?
Kind (Kubernetes in Docker) is a Kubernetes cluster tool built on Docker. It is CNCF certified and supports multi-node clusters, including high availability clusters. And support Linux, macOS and Windows operating system, simple operation, low learning cost, very suitable for local construction based on Kubernetes development/testing environment.