1、场景

用nerdctl登录镜像仓库192.168.0.190(Harbor),报错

ERRO[0006] failed to call tryLoginWithRegHost            error="failed to call rh.Client.Do: Get \"https://192.168.0.190/v2/\": dial tcp 192.168.0.190:443: connect: connection refused" i=0
FATA[0006] failed to call rh.Client.Do: Get "https://192.168.0.190/v2/": dial tcp 192.168.0.190:443: connect: connection refused
dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP

2、解决办法

由于机器装了docker和containerd

2.1 所有的Kubernetes节点的Docke,都需要添加insecure-registries配置:

master节点:

dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP

node节点:

dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP

systemctl daemon-reload 
systemctl restart docker

2.2  如果Kubernetes集群采用的是Containerd作为的Runtime,配置insecure-registry只需要在

Containerd配置文件的mirrors下添加自己的镜像仓库地址即可

master节点:
vi /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."192.168.0.190"]
          endpoint= ["http://192.168.0.190"]

 
dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP
node节点:
dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP
systemctl restart containerd

3、创建hosts.toml文件

mkdir -p /etc/containerd/certs.d/192.168.0.190 (Harbor镜像仓库地址:192.168.0.190)
cd /etc/containerd/certs.d/192.168.0.190
vi hosts.toml
server = "http://192.168.0.190"
[host."http://192.168.0.190"]
  capabilities = ["pull", "resolve","push"]
  skip_verify = true

dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP

4、验证

nerdctl login 192.168.0.190

dial tcp 192.168.0.190:443: connect: connection refused-LMLPHP

04-25 10:08