In this article we will look how we can configure our kind cluster in a declarative way
Introduction
kind cluster can be created and configured in a declarative way
We can define our desired state for kind cluster in a YAML file
YAML file follows Kubernetes conventions and versioning
Parameters passed in the CLI take precedence over their equivalent in the config file
Usage
Simple Cluster
Creating a simple cluster having one control plane and two worker nodes
$ cat kind.yml
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
name: dev
nodes:
- role: control-plane
- role: worker
- role: worker
$ kind create cluster --config kind.yml
Creating cluster "dev" ...
โ Ensuring node image (kindest/node:v1.26.3) ๐ผ
โ Preparing nodes ๐ฆ ๐ฆ ๐ฆ
โ Writing configuration ๐
โ Starting control-plane ๐น๏ธ
โ Installing CNI ๐
โ Installing StorageClass ๐พ
โ Joining worker nodes ๐
Set kubectl context to "kind-dev"
You can now use your cluster with:
kubectl cluster-info --context kind-dev
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
dev-control-plane Ready control-plane 53s v1.26.3
dev-worker Ready <none> 16s v1.26.3
dev-worker2 Ready <none> 29s v1.26.3
HA Cluster
Creating a cluster having multiple control planes for high availability
$ cat kind.yml
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
name: dev
nodes:
- role: control-plane
- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
$ kind create cluster --config kind.yml
Creating cluster "dev" ...
โ Ensuring node image (kindest/node:v1.26.3) ๐ผ
โ Preparing nodes ๐ฆ ๐ฆ ๐ฆ ๐ฆ ๐ฆ ๐ฆ
โ Configuring the external load balancer โ๏ธ
โ Writing configuration ๐
โ Starting control-plane ๐น๏ธ
โ Installing CNI ๐
โ Installing StorageClass ๐พ
โ Joining more control-plane nodes ๐ฎ
โ Joining worker nodes ๐
Set kubectl context to "kind-dev"
You can now use your cluster with:
kubectl cluster-info --context kind-dev
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
dev-control-plane Ready control-plane 2m32s v1.26.3
dev-control-plane2 Ready control-plane 2m18s v1.26.3
dev-control-plane3 Ready control-plane 74s v1.26.3
dev-worker Ready <none> 56s v1.26.3
dev-worker2 Ready <none> 56s v1.26.3
dev-worker3 Ready <none> 68s v1.26.3
Changing Kubernetes Version
We can change the Kubernetes version by setting the nodeโs container image and itโs mandatory to include the sha256 value with the image
$ cat kind.yml
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
name: dev
nodes:
- role: control-plane
image: kindest/node:v1.27.0@sha256:c6b22e613523b1af67d4bc8a0c38a4c3ea3a2b8fbc5b367ae36345c9cb844518
- role: worker
image: kindest/node:v1.27.0@sha256:c6b22e613523b1af67d4bc8a0c38a4c3ea3a2b8fbc5b367ae36345c9cb844518
- role: worker
image: kindest/node:v1.27.0@sha256:c6b22e613523b1af67d4bc8a0c38a4c3ea3a2b8fbc5b367ae36345c9cb844518
$ kind create cluster --config kind.yml
Creating cluster "dev" ...
โ Ensuring node image (kindest/node:v1.27.0) ๐ผ
โ Preparing nodes ๐ฆ ๐ฆ ๐ฆ
โ Writing configuration ๐
โ Starting control-plane ๐น๏ธ
โ Installing CNI ๐
โ Installing StorageClass ๐พ
โ Joining worker nodes ๐
Set kubectl context to "kind-dev"
You can now use your cluster with:
kubectl cluster-info --context kind-dev
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
dev-control-plane Ready control-plane 61s v1.27.0
dev-worker Ready <none> 42s v1.27.0
dev-worker2 Ready <none> 41s v1.27.0
Cleanup
Delete the cluster after use
$ kind delete cluster --name dev
Deleting cluster "dev" ...
Deleted nodes: ["dev-worker2" "dev-worker" "dev-control-plane"]
Top comments (0)