In k8s world, there is a need for testing before going production. One among them is using kind
to build local cluster.
There are many ways in official document, here is my prefer way using yaml to define my expectation.
Creating a yaml file named kind.yaml
as below to configure 1 master and 2 workers:
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
image: kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047
extraPortMappings:
- containerPort: 30778
hostPort: 30778
listenAddress: "0.0.0.0"
protocol: tcp
- role: worker
image: kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047
- role: worker
image: kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047
Install kind if not have. If you're using MacOS, run: brew install kind
for package manager using brewk
Run command to setup cluster: kind create cluster --name local --config kind.yaml
Here is my result, tested in Mac M1 chip:
kind create cluster --name local --config kind.yaml
Creating cluster "local" ...
â Ensuring node image (kindest/node:v1.22.0) đŧ
â Preparing nodes đĻ đĻ đĻ
â Writing configuration đ
â Starting control-plane đšī¸
â Installing CNI đ
â Installing StorageClass đž
â Joining worker nodes đ
Set kubectl context to "kind-local"
You can now use your cluster with:
kubectl cluster-info --context kind-local
Have a nice day! đ
With k8s contents as below:
kubectl config set-context local-kind Context "local-kind" created.
kubectl get node
NAME STATUS ROLES AGE VERSION
local-control-plane Ready control-plane,master 7m58s v1.22.0
local-worker Ready <none> 7m26s v1.22.0
local-worker2 Ready <none> 7m26s v1.22.0
Top comments (0)