当执行命令初始化报错的时候,

kubeadm init \
--kubernetes-version=v1.17.4 \
--pod-network-cidr=10.244.0.0/16 \
--service-cidr=10.96.0.0/12 \
--apiserver-advertise-address=192.168.159.1

已经试过这种拉取方式

docker pull mirrorgcrio/kube-apiserver:v1.17.4
docker pull mirrorgcrio/kube-controller-manager:v1.17.4
docker pull mirrorgcrio/kube-scheduler:v1.17.4
docker pull mirrorgcrio/kube-proxy:v1.17.4
docker pull mirrorgcrio/pause:3.1
docker pull mirrorgcrio/etcd:3.4.3-0
docker pull mirrorgcrio/coredns:1.6.5

不妨看一下我们是否一开始就错了,执行命令kubeadm config images list查看适合我们的版本,因为现在网上教程问题,所以照搬可能会出错。

[root@master ~]# kubeadm config images list
I1116 19:23:52.472784    8979 version.go:251] remote version is much newer: v1.22.3; falling back to: stable-1.17
W1116 19:23:53.520305    8979 validation.go:28] Cannot validate kube-proxy config - no validator is available
W1116 19:23:53.520322    8979 validation.go:28] Cannot validate kubelet config - no validator is available
k8s.gcr.io/kube-apiserver:v1.17.17
k8s.gcr.io/kube-controller-manager:v1.17.17
k8s.gcr.io/kube-scheduler:v1.17.17
k8s.gcr.io/kube-proxy:v1.17.17
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.4.3-0
k8s.gcr.io/coredns:1.6.5

查看到我的版本跟教程上面的1.17.14有出入。则手动修改把下列代码写入xx.sh文件中 sh xx.sh执行

images=( 
kube-apiserver:v1.17.7
kube-controller-manager:v1.17.7
kube-scheduler:v1.17.7
kube-proxy:v1.17.7
pause:3.1
etcd:3.4.3-0
coredns:1.6.5 
)

for imageName in ${images[@]} ; do
	docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName 
	docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$imageNamek8s.gcr.io/$imageName
	docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
done

继续初始化即可,记得修改初始化代码版本号

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐