k8s修改/etc/docker/daemon.json为"exec-opts": ["native.cgroupdriver=systemd"]无法获取镜像问题

问题描述

部署k8s环境后,准备新建一个deployment发现拉取pod时无法拉取到镜像,报错如下:

Failed to pull image "nginx:1.14.2": rpc error: code = Unknown desc = error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/29/295c7be079025306c4f1d65997fcf7adb411c88f139ad1d34b537164aa060369/data?verify=1721837818-JjLOluubolRdRzcQq4CZ3GPwPIY%3D: dial tcp 156.233.67.243:443: connect: connection refused


查看docker.service报错

Jul 24 23:30:52 k8s-master01 dockerd[1207]: time="2024-07-24T23:30:52.909292606+08:00" level=error msg="Not continuing with pull after error: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/29/295c7be079025306c4f1d65997fcf7adb411c88f139ad1d34b537164aa060369/data?verify=1721838031-BwtlCeJaP4VXqTOao3b0cXLkePY%3D: dial tcp 108.160.165.189:443: connect: connection refused"

解答思路

根据上诉报错,经过网络问题排查以后发现本身网络并没有问题,发现无法连接到https://production.cloudflare.docker.com/,故推断是无法连接Docker Hub,估计是国外镜像仓库有关,所以获取不到镜像

解决方法

修改/etc/docker/daemon.json,新增"registry-mirrors": ["https://kn0t2bca.mirror.aliyuncs.com"]",修改为阿里云的镜像仓库地址

{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "registry-mirrors": ["https://kn0t2bca.mirror.aliyuncs.com"]
}

修改后问题解决(只改了master01的节点,所以只有master01上的pod恢复正常)

扩展点

在修改其他master节点跟node节点时,需要将docker服务与kubelet服务一起重启,否则其他工作节点将处于不可用状态,所有工作节点修改完并重启服务后恢复正常

node节点正常

pod正常

posted @ 2024-07-25 00:36  Yusir-SRE  阅读(82)  评论(0编辑  收藏  举报