k8s集群新增的worker机后无法拉取镜像的解决办法
今天在k8s集群新加一台worker机器后,worker机无法正常拉取镜像,报错信息如下:
ErrImagePull: rpc error: code = Unknown desc = Error response from daemon: Get https://dhub.xxx.cn/v2/: dial tcp 192.168.100.110:443: connect: connection refused
上面的信息会出现几秒钟,后面在服务pod上的信息会变成如下信息:
imagepullbackoff: back-off pulling image
出现这个原因是因为:新加的worker默认使用https来访问镜像仓库,而我们内网的 http://dhub.xxx.cn/ 镜像仓库不支持https访问。我们需要改变访问方式,将https改为http。
方法如下:
- 1)通过ssh登录worker机器,找到 /etc/docker/daemon.json
- 2)使用vim打开文件,将内容替换为:
{
"dns": ["192.168.0.6", "192.168.0.7"],
"insecure-registries": [
"dhub.xxx.cn"
],
"registry-mirrors": [
"https://gt1oxu01.mirror.aliyuncs.com"
]
}
也可以 mv daemon.json daemon.json.bak
,然后再vim 一个 daemon.json 文件,切换到insert模式并粘贴,保存退出。
记得使用cat命令二次确认内容已经得到修正,修改完成后通过reboot重启服务器。
如果一切ok,重新部署服务后将会自动从镜像仓库拉取docker镜像,完成服务的部署。
另一篇关于无法拉取镜像的文章:https://tantiyu.com/archives/38.html
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。