Kind配置
以下脚本快速创建一个包含1个控制平面节点和4个工作节点的Kind集群:kind-cluster.yaml
这里使用的是
v1.27.3版本的K8S,更多K8S版本请查看:https://hub.docker.com/r/kindest/node/tags
kind-cluster.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: kind-cluster
nodes:
# 控制平面节点
- role: control-plane
image: kindest/node:v1.27.3
# Worker节点
- role: worker
image: kindest/node:v1.27.3
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
name: node0
- role: worker
image: kindest/node:v1.27.3
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
name: node1
- role: worker
image: kindest/node:v1.27.3
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
name: node2
- role: worker
image: kindest/node:v1.27.3
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
name: node3
保存为 kind-config.yaml。
集群创建与查看
创建集群
运行以下命令创建集群:
kind create cluster --config kind-cluster.yaml
列出集群
等待2-5分钟:
kind get clusters
预期输出:
kind-cluster
验证节点
kubectl get nodes
预期输出:
NAME STATUS ROLES AGE VERSION
kind-cluster-control-plane Ready control-plane 42s v1.27.3
node0 Ready <none> 20s v1.27.3
node1 Ready <none> 20s v1.27.3
node2 Ready <none> 20s v1.27.3
node3 Ready <none> 20s v1.27.3
删除集群
kind delete clusters kind-cluster