k8s containerd 配置 http访问harbor image【最新--官方文档】

不看官方文档的代价:在搜索了很多中文资料发现配置了都不起作用,浪费了很多时间。

https://github.com/containerd/containerd/blob/main/docs/cri/config.md#registry-configuration

The old CRI config pattern for specifying registry.mirrors and registry.configs has been DEPRECATED. You should now point your registry config_path to the path where your hosts.toml files are located. 也就是说直接在/etc/containerd/config.toml里配置 registry.mirrors已经失效了。

最新的配置方法是只在config.toml 中指定hosts.toml的config_path

plugins."io.containerd.grpc.v1.cri".registry

config_path = "/etc/containerd/certs.d"

在hosts.toml配置真正的harbor的URL, 默认是https,这里改成了http

vim /etc/containerd/certs.d/registry.imagehub.com/hosts.toml

server = "http://registry.imagehub.com"

host."http://registry.imagehub.com"

capabilities = ["pull", "resolve", "push"]

skip_verify = true

修改完,需要daemon-reload, restart containerd

验证pull image是否成功:

ctr images pull --hosts-dir "/etc/containerd/certs.d" registry.imagehub.com/library/hello_world:v2

网元yaml配置image地址:

cat hello_world.yaml

containers:

  • name: hello-world-container

image: registry.imagehub.com/library/hello_world:v2

kubectl get pods --all-namespaces

NAMESPACE NAME READY STATUS RESTARTS AGE

default hello-world-6c8d6fb999-8fdsd 1/1 Running 0 52m

相关推荐
能不能别报错8 分钟前
K8s学习笔记(十九) K8s资源限制
笔记·学习·kubernetes
qq_2642208912 分钟前
K8s存储-PV与PVC
云原生·容器·kubernetes
kyle-fang2 小时前
tritonserver的docker镜像中运行onnxruntime-gpu,报错segmentationfault
容器
vue学习3 小时前
docker 运行容器限制内存、限制磁盘 IO
运维·docker·容器
山塘小鱼儿4 小时前
open-webui docker高速下载&本地部署
运维·docker·容器
鸠摩智首席音效师11 小时前
如何检查本地是否存在 Docker 镜像 ?
docker·容器
鸠摩智首席音效师11 小时前
如何在 Docker 中设置环境变量 ?
docker·容器
舰长1151 天前
k8s 持久化存储方案-PVC
云原生·容器·kubernetes
南方以南_1 天前
对比k8s的service和kube-proxy
云原生·容器·kubernetes
爱宇阳1 天前
从零开始部署 GitLab CE 18.4.2:Docker Compose 新手教程
docker·容器·gitlab