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

相关推荐
c无序28 分钟前
【Docker-13】Docker Container容器
运维·docker·容器
YXWik61 小时前
Windows卸载重装Docker
windows·docker·容器
云达闲人2 小时前
Proxmox VE 用户与权限管理命令大全
运维·网络·云原生·容器·proxmox·用户权限管理·命令大全
喆星时瑜2 小时前
【Docker】运行错误提示 unknown shorthand flag: ‘d‘ in -d ----详细解决方法
运维·docker·容器
David爱编程2 小时前
K8s中Pod 和容器到底啥关系?
云原生·容器
KubeSphere2 小时前
告别繁琐!KubeSphere v3.4.x 到 v4.x 平滑升级全攻略
kubernetes
RedCong3 小时前
kubectl命令补全以及oc命令补全
云原生·kubernetes·kubectl命令补全
放情5 小时前
关于k8s的部署
java·docker·kubernetes
~卷心菜~5 小时前
【Kubernetes基础--Service深入理解】--查阅笔记4
笔记·容器·kubernetes
❀͜͡傀儡师6 小时前
Docker部署禅道21.6开源版本
运维·docker·容器