containerd:配置https私有镜像仓库的最新方法

随着containerd应用越来越广泛,我们必须紧跟官网的节奏。

之前配置https私有镜像仓库的方法比较繁琐,并且不易梳理,下边介绍一下目前最新的配置方法。

配置https私有镜像仓库

我假设你现在已经有私有仓库并且是https

再假设你的harbor域名是harbor.example.cn

你只需要在/etc/containerd/config.toml中配置一下证书的路径:

bash 复制代码
...
    [plugins."io.containerd.grpc.v1.cri".registry]
      config_path = "/etc/containerd/certs.d"
...

然后创建对应的目录及文件

bash 复制代码
mkdir -p /etc/containerd/certs.d/harbor.example.cn

cat > hosts.toml << EOF
server = "https://harbor.example.cn"

[host."https://harbor.example.cn"]
  capabilities = ["pull", "resolve", "push"]
  skip_verify = true
EOF

skip_verify = true 表示跳过TLS的验证,如果想要更安全一些就将它修改为false,上传证书并指定路径

bash 复制代码
[root@anilis-k8s-03 harbor.example.cn]# ls
ca.crt  harbor.example.cn.crt  harbor.example.cn.key

修改配置:

bash 复制代码
cat > hosts.toml << EOF
server = "https://harbor.example.cn"

[host."https://harbor.example.cn"]
  capabilities = ["pull", "resolve", "push"]
  skip_verify = false
  ca = "ca.crt"
EOF

最后重启containerd

bash 复制代码
systemctl restart containerd.service

再次拉取镜像,都可以正常访问了!

如果你还有其他域名需要加,那就创建对应的目录就可以了!

参考官网

containerd:
https://github.com/containerd/containerd/blob/main/docs/cri/config.md
https://github.com/containerd/containerd/blob/main/docs/hosts.md

harbor自签证书:
https://goharbor.io/docs/2.11.0/install-config/configure-https/

相关推荐
行者Sun198911 天前
【K8s】专题十三:Kubernetes 容器运行时之 Docker 与 Containerd 详解
docker·云原生·容器·kubernetes·containerd
一个在高校打杂的22 天前
解决ssl certificates updated-生成环境中的实例
linux·ssl·harbor
rainsc25 天前
k8s新版本使用container而不是docker导致创建pod一直提示证书问题
k8s·harbor·container
d3126975101 个月前
自建Gitlab和Gitlab runner并推送镜像到Harbor
docker·gitlab·harbor·cicd·gitlab-runner
lldhsds2 个月前
Harbor系列之1:介绍、架构及工作流程说明
云原生·kubernetes·harbor
forestsea2 个月前
Docker、containerd、CRI-O 和 runc 之间的区别
docker·containerd·runc·crio·docker被k8s淘汰
NingKangMing2 个月前
Harbor企业docker私服安装及SSL安全访问配置
安全·docker·ssl·harbor·docker私服
lldhsds2 个月前
Harbor私有仓库部署与配置-http
云原生·harbor·devops
张兆坤的那些事3 个月前
kubernetes使用私有仓库harbor创建Pod
kubernetes·containerd·harbor