What is Kind?
What are the characteristics of kind?
- It is very fast to create and start k8s clusters with low resource consumption.
- Support the creation of multi node k8s clusters, including high availability mode.
- kind supports Linux, macOS and Windows
- It is one of the k8s cluster installation methods certified by CNCF
How do I install kind?
kind is a binary program. You can download the corresponding version and increase the Execution Authority:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 chmod +x ./kind mv ./kind /usr/bin/kind kind version
How to create a new k8s cluster through kind?
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl kubectl version --client
root@e5pc-vm-01:~# kind create cluster --name myk8s-01
Â
Creating cluster "myk8s-01" ... â Ensuring node image (kindest/node:v1.21.1) đŧ â Preparing nodes đĻ â Writing configuration đ â Starting control-plane đšī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ â Installing CNI đ â Installing StorageClass đž Set kubectl context to "kind-myk8s-01" You can now use your cluster with: kubectl cluster-info --context kind-myk8s-01 Have a nice day! đ
So far, we have got an available k8s cluster:
root@e5pc-vm-01:~# kubectl get nodes NAME STATUS ROLES AGE VERSION myk8s-01-control-plane Ready control-plane,master 66s v1.21.1
Inside story of kind creating k8s clusters
root@e5pc-vm-01:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 2b4cba85892a 2 days ago 72.8MB kindest/node <none> 32b8b755dee8 9 months ago 1.12GB
Â
root@e5pc-vm-01:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b4bde05b0190 kindest/node:v1.21.1 "/usr/local/bin/entr..." 12 minutes ago Up 12 minutes 127.0.0.1:42267->6443/tcp myk8s-01-control-plane
root@e5pc-vm-01:~# cat .kube/config apiVersion: v1 clusters: - cluster: certificate-authority-data: xxxx server: https://127.0.0.1:42267 name: kind-myk8s-01 contexts: - context: cluster: kind-myk8s-01 user: kind-myk8s-01 name: kind-myk8s-01 current-context: kind-myk8s-01 kind: Config preferences: {} users: - name: kind-myk8s-01 user: client-certificate-data: xxxx client-key-data: xxxx
The architecture diagram of kind creating k8s cluster is as follows:
Full usage of kind program
- kind create cluster
- --Image specifies the name of the node image. The default is kindest/node
- --Name specifies the name of the cluster to be created
- --config kind-example-config.yaml
- --kubeconfig string specifies the file path of the generated kubeconfig. The default is $kubeconfig or $home / kube/config
- Common: kind create cluster --config=xxxcfg --name=xxxname
- kind delete cluster xxxx
- kind get clusters: view all the k8s clusters created by kind
- kind get kubeconfig --name cluster name [the -- name parameter must be filled in, and the default name is kind]
- kind completion
- kind export kubeconfig --name=xxx --kubeconfig=kubeconfigpath
- Export kubeconfig connection configuration file of k8s cluster in kind
Advanced use of kind
1. Create k8s cluster from configuration file
The cluster creation operation shown above is the simplest single master cluster. Of course, kind can create a more complete cluster. This requires the configuration file mode to create a cluster:
root@e5pc-vm-01:~# cat kindcfg-tccc.biz.yml kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane - role: worker - role: worker - role: worker root@e5pc-vm-01:~# kind create cluster --name myk8s-02 --config ./kindcfg-tccc.biz.yml
2. Set the new k8s cluster to load the image from the private http repository
The configuration file is as follows:
kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 containerdConfigPatches: - |- [plugins."io.containerd.grpc.v1.cri".registry.mirrors."harbor.xxxx.top:60666"] endpoint = ["http://harbor.xxxx.top:60666"] nodes: - role: control-plane - role: worker
3. Complete configuration file example
Address: https://raw.githubusercontent.com/kubernetes-sigs/kind/main/site/content/docs/user/kind-example-config.yaml
# this config file contains all config fields with comments # NOTE: this is not a particularly useful config file kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 # patch the generated kubeadm config with some extra settings kubeadmConfigPatches: - | apiVersion: kubelet.config.k8s.io/v1beta1 kind: KubeletConfiguration evictionHard: nodefs.available: "0%" # patch it further using a JSON 6902 patch kubeadmConfigPatchesJSON6902: - group: kubeadm.k8s.io version: v1beta2 kind: ClusterConfiguration patch: | - op: add path: /apiServer/certSANs/- value: my-hostname # 1 control plane node and 3 workers nodes: # the control plane node config - role: control-plane # the three workers - role: worker - role: worker - role: worker
summary
kind is a very helpful tool for learning and testing k8s clusters. It starts quickly with low resource consumption, and it is also one of the installation tools compatible with CNCF certification. You can rest assured to use it.
reference material
- Official documents: https://kind.sigs.k8s.io/
- GitHub home page: https://github.com/kubernetes-sigs/kind/