WSL2 使用Kind创建Kubernetes开发集群环境


1.安装 WSL2

2.安装 Docker Desktop

3.安装 Kind

curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-$(uname)-amd64

chmod +x ./kind

sudo mv ./kind /usr/local/bin/

kind version

4.创建 单Master集群(可省略)

# pull image kindest/node:v1.18.2 docker pull ccr.ccs.tencentyun.com/kindest/node:v1.18.2 docker tag ccr.ccs.tencentyun.com/kindest/node:v1.18.2 kindest/node:v1.18.2 docker rmi ccr.ccs.tencentyun.com/kindest/node:v1.18.2
# create master
kind create cluster --image kindest/node:v1.18.2 --name k8s

kubectl get nodes

# Delete the existing cluster
kind delete cluster --name k8s

5. 创建 多节点集群

 

# Create a config file for a 3 nodes cluster
cat << EOF > kind-3nodes.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
  - role: worker
  - role: worker
EOF

# pull image kindest/node:v1.18.2
docker pull ccr.ccs.tencentyun.com/kindest/node:v1.18.2
docker tag ccr.ccs.tencentyun.com/kindest/node:v1.18.2 kindest/node:v1.18.2
docker rmi ccr.ccs.tencentyun.com/kindest/node:v1.18.2

# Create a new cluster with the config file
kind create cluster --image kindest/node:v1.18.2 --name k8s --config ./kind-3nodes.yaml

# Check how many nodes it created
kubectl get nodes

 

以上操作,我们创建了一个三节点集群

kubectl get all --all-namespaces

 

 6.创建仪表板(可选)

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml

 

 

kubectl get all -n kubernetes-dashboard

kubectl proxy

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM