环境介绍:
master 192.168.2.18
node1 192.168.2.19
node2 192.168.2.20
CentOS 7.5
Docker 19.03.13
2核+CPU,2GB+内存
报错信息:
初始化Kubernetes时出现下面报错
[root@k8s-master ~]# kubeadm init --kubernetes-version=v1.22.1 --apiserver-advertise-address=192.168.1.18 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --image-repository registry.aliyuncs.com/google_containers [init] Using Kubernetes version: v1.22.1 [preflight] Running pre-flight checks [preflight] Pulling images required for setting up a Kubernetes cluster [preflight] This might take a minute or two, depending on the speed of your internet connection [preflight] You can also perform this action in beforehand using 'kubeadm config images pull' error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR ImagePull]: failed to pull image registry.aliyuncs.com/google_containers/coredns:v1.8.4: output: Error response from daemon: manifest for registry.aliyuncs.com/google_containers/coredns:v1.8.4 not found: manifest unknown: manifest unknown , error: exit status 1 [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` To see the stack trace of this error execute with --v=5 or higher
从上面的报错可以看出这个问题是因为在初始化Kubernetes的时候需要拉取阿里云的registry.aliyuncs.com/google_containers/coredns:v1.8.4
这个版本的镜像,拉取失败就会报这个错误,我们可以手动拉取一下。
解决方法:
由于安装的是Kubernetes v1.22.1版本,在初始化的时候报错信息中提示需要registry.aliyuncs.com/google_containers/coredns:v1.8.4
版本的coredns镜像,手动拉取registry.aliyuncs.com/google_containers/coredns:v1.8.4
版本的镜像时发现没有,所以就只能拉取一个默认版本的阿里云coredns镜像,拉取下来之后自己再手动修改一下镜像的tag信息为v1.8.4版本。
[root@k8s-master ~]# docker pull registry.aliyuncs.com/google_containers/coredns //手动拉取默认版本的coredns镜像 Using default tag: latest latest: Pulling from google_containers/coredns c6568d217a00: Pull complete bc38a22c706b: Pull complete Digest: sha256:6e5a02c21641597998b4be7cb5eb1e7b02c0d8d23cce4dd09f4682d463798890 Status: Downloaded newer image for registry.aliyuncs.com/google_containers/coredns:latest registry.aliyuncs.com/google_containers/coredns:latest [root@k8s-master ~]# docker images //查看拉取下来的coredns镜像 ... registry.aliyuncs.com/google_containers/coredns latest 8d147537fb7d 3 months ago 47.6MB ... [root@k8s-master ~]# docker tag registry.aliyuncs.com/google_containers/coredns:latest registry.aliyuncs.com/google_containers/coredns:v1.8.4 //将拉取的默认版本的coredns镜像tag信息修改为v1.8.4版本 [root@k8s-master ~]# docker images //查看修改的coredns镜像tag信息 ... registry.aliyuncs.com/google_containers/coredns latest 8d147537fb7d 3 months ago 47.6MB registry.aliyuncs.com/google_containers/coredns v1.8.4 8d147537fb7d 3 months ago 47.6MB ...
出现以上coredns镜像版本必须为v1.8.4的问题原因可能是因为我安装的是比较新的Kubernetes v1.22.1版本,在安装Kubernetes v1.20.8的版本时不会有这个问题!