安装Docker Desktop
去官网下载,新版已经比前几年好用多了
安装前要去windows功能里边开启Hyper-V
和适用于Linux的Windows子系统
若安装完,启动显示乱码,打开管理员shell,执行完重启即可
netsh winsock reset
新版Docker Desktop会自带kubectl
配置Docker Desktop镜像源
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"features": {
"buildkit": true
},
"registry-mirrors": [
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
]
}
配置kind
下载 Kind,官方最新是v0.17.0,但是没有windows版本,故下载v0.16.0
curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.16.0/kind-windows-amd64
下载后改名 kind.exe,放到 C:\Windows\
目录下即可全局
如果前边Docker Desktop没有自动配置好kubectl
那么,下载 kubectl,下载后放到 C:\Windows\
目录下即可全局。
curl.exe -LO "https://dl.k8s.io/release/v1.25.0/bin/windows/amd64/kubectl.exe"
使用kind创建集群
准备配置文件
创建单个节点的k8s集群的配置文件k8s-test.yaml
,镜像使用v1.21.14
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: k8s-test
nodes:
- role: control-plane
image: kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1
networking:
apiServerAddress: "127.0.0.1"
apiServerPort: 6443
创建五个节点(3个master,2个worker)的k8s集群的配置文件k8s32-config.yaml
,镜像使用v1.21.14
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: k8s
nodes:
- role: control-plane
image: kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1
- role: control-plane
image: kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1
- role: control-plane
image: kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1
- role: worker
image: kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1
- role: worker
image: kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1
networking:
apiServerAddress: "127.0.0.1"
apiServerPort: 6443
创建集群
使用配置文件k8s-test.yaml
创建单个节点的k8s集群
C:\k8s-platform\kubeconfig>kind create cluster --config k8s-test.yaml
Creating cluster "k8s-test" ...
• Ensuring node image (kindest/node:v1.21.14)
标签:node,kind,14,v1.21,Windows,nginx,集群,k8s
From: https://www.cnblogs.com/ltaodream/p/16843946.html