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