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/

相关推荐
fanruitian11 天前
使用harbor搭建私有仓库
k8s·harbor
虚神界熊孩儿12 天前
Linux下修改docker和harbor默认网段的方法
linux·docker·harbor
飞翔沫沫情16 天前
基于OpenEuler的iSulad容器引擎部署实践手册
containerd·cni·csi·cri·容器引擎·isulad·国产容器引擎
womenrendeme1 个月前
wsl登录harbor dial tcp: lookup xxx.xxx.xxx: no such host
harbor·wsl
VermiliEiz1 个月前
二进制文件方式部署k8s(3)
云原生·容器·kubernetes·containerd
木二_1 个月前
附056.Kubernetes_v1.34.3三节点集群-CentOS版
云原生·容器·kubernetes·centos·containerd·ingress·longhorn
岚天start1 个月前
Containerd 运行时的 K8S 集群离线导入镜像的方案
容器·containerd·容器运行时
玄德公笔记2 个月前
GPU节点接入k8s集群的处理
docker·kubernetes·gpu·containerd·nvidia·runtime·fabricmanager
菩提树下种菩提2 个月前
开源制品管理工具选型,Harbor or Hadess全面对比分析
harbor·hadess·开源制品管理工具·对比分析
爱宇阳3 个月前
GitLab CI/CD 集成 Harbor 全面教程
ci/cd·gitlab·harbor