Using kind to Test Kubernetes
kind is a tool for running local Kubernetes clusters using Docker container “nodes”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.
It requires Docker to be installed (it may work with podman but I've not tried) and the kind binary which can be installed in various ways
1brew install kind
2or
3sudo port selfupdate && sudo port install kind
4or
5choco install kind
6or
7go install sigs.k8s.io/kind@v0.17.0
A basic cluster can be spun up with kind create cluster
1➜ kind (⎈ |N/A:default) kind create cluster
2Creating cluster "kind" ...
3✓ Ensuring node image (kindest/node:v1.25.3) 🖼
4✓ Preparing nodes 📦
5✓ Writing configuration 📜
6✓ Starting control-plane 🕹️
7✓ Installing CNI 🔌
8✓ Installing StorageClass 💾
9Set kubectl context to "kind-kind"
10You can now use your cluster with:
11
12kubectl cluster-info --context kind-kind
13
14Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/
15➜ kind (⎈ |kind-kind:default) kubectl get nodes
16NAME STATUS ROLES AGE VERSION
17kind-control-plane NotReady control-plane 15s v1.25.3
18➜ kind (⎈ |kind-kind:default)
Then deleted with kind delete cluster
1➜ kind (⎈ |kind-kind:default) kind delete cluster
2Deleting cluster "kind" ...
More complex configurations can be defined via a yaml file. Full details on the options can be found here
A control plane node and 3 workers
1kind: Cluster
2apiVersion: kind.x-k8s.io/v1alpha4
3nodes:
4- role: control-plane
5- role: worker
6- role: worker
7- role: worker
The yaml file is used via the --config option
1➜ kind (⎈ |N/A:default) kind create cluster --config=basic.yml
2Creating cluster "kind" ...
3 ✓ Ensuring node image (kindest/node:v1.25.3) 🖼
4 ✓ Preparing nodes 📦 📦 📦 📦
5 ✓ Writing configuration 📜
6 ✓ Starting control-plane 🕹️
7 ✓ Installing CNI 🔌
8 ✓ Installing StorageClass 💾
9 ✓ Joining worker nodes 🚜
10Set kubectl context to "kind-kind"
11You can now use your cluster with:
12
13kubectl cluster-info --context kind-kind
14
15Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/
16➜ kind (⎈ |kind-kind:default) kubectl get nodes
17NAME STATUS ROLES AGE VERSION
18kind-control-plane Ready control-plane 33s v1.25.3
19kind-worker Ready <none> 13s v1.25.3
20kind-worker2 Ready <none> 13s v1.25.3
21kind-worker3 Ready <none> 13s v1.25.3
A specific Kubernetes version
1kind create cluster --image="kindest/node:v1.24.1"
comments powered by Disqus