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

相关推荐
你的钉钉响了5 小时前
用 kubeadm-ha 部署高可用 Kubernetes 集群
云原生·容器·kubernetes·ansible·高可用集群·kubeadm-ha
Z21-X15 小时前
云原生运维学习笔记:Kubernetes Service 发现、类型与 kube-proxy 实战
运维·笔记·学习·云原生·kubernetes
SeanQhl1 天前
openEuler 下 Docker 镜像操作与多阶段构建瘦身
docker·容器·镜像·openeuler·dockerfile
AR-26710-2 天前
docker Day4——命令小结与实操作业
运维·docker·容器
AR-26710-2 天前
docker Day3——镜像,容器,日志与元数据
运维·docker·容器
SeanQhl3 天前
openEuler 下 Docker 静态安装与容器基础操作
linux·docker·云原生·容器·openeuler
xbzb3 天前
Kubernetes ReplicaSet:副本数自愈、标签接管与 orphan 删除实测
容器·kubernetes·删除·pod·replicaset·orphan
AR-26710-4 天前
docker Day2——镜像 / 容器 / 仓库
运维·docker·容器
好用斋4 天前
拾光坞G2使用新版Docker懒人包:一键安装、一键升级、一键卸载
java·docker·容器
赤生云电竞4 天前
算力调度系统架构实践:计费、配额与抢占策略设计——基于Kubernetes 1.28与YARN 3.3的参数选型
贪心算法·系统架构·kubernetes