kubeadm init [ERROR ImagePull]: failed to pull image ​registry.k8s.io​​ 解决方法

时间:2023-01-24 07:59:29

​https://blog.itwk.cc​

由于国内网络原因,kubeadm init部署集群会卡住不动,,报错如下: error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR ImagePull]: failed to pull image registry.k8s.io/kube-apiserver:v1.25.6: output: E0124 00:28:25.369652 3299 remote_image.go:171] "PullImage from image service failed" err="rpc error: code = Unknown desc = Error response from daemon: Head "​​https://asia-east1-docker.pkg.dev/v2/k8s-artifacts-prod/images/kube-apiserver/manifests/v1.25.6​​": dial tcp 64.233.189.82:443: connect: connection refused" image="registry.k8s.io/kube-apiserver:v1.25.6" time="2023-01-24T00:28:25+08:00" level=fatal msg="pulling image: rpc error: code = Unknown desc = Error response from daemon: Head "​​https://asia-east1-docker.pkg.dev/v2/k8s-artifacts-prod/images/kube-apiserver/manifests/v1.25.6​​": dial tcp 64.233.189.82:443: connect: connection refused" , error: exit status 1

截图如下

解决方法

因为要下载K8s所需的Docker镜像文件,众所周知K8s是谷歌研发出来的,registry服务器在谷歌,国内连不上,所以这里我们要用阿里云镜像

运行kubeadm init时加上阿里云镜像的参数即可

such as

kubeadm init --kubernetes-version=v1.25.6 --pod-network-cidr=10.224.0.0/16 --apiserver-advertise-address=172.25.80.10 --cri-socket unix:///var/run/cri-dockerd.sock --image-repository=registry.aliyuncs.com/google_containers

最后添加​​--image-repository=registry.aliyuncs.com/google_containers​​ 即可