-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[咨询]能否用代理地址拉取后Rename成原来镜像地址 #1
Comments
有点没太明白这个场景,可以再详细一点么
…---原始邮件---
发件人: ***@***.***>
发送时间: 2024年1月25日(周四) 下午5:45
收件人: ***@***.***>;
抄送: ***@***.***>;
主题: [ketches/registry-proxy] [咨询]能否用代理地址拉取后Rename成原来镜像地址 (Issue #1)
场景:今天用Dockerfile构建了本地镜像(未推到Hub),拉取策略:IfNotPresent。本想直接引用本地镜像,但是pod一直报拉取失败,后来才发现镜像直接替换成了docker.ketches.cn/xxx.最后按照这个名称构建镜像后OK了
问题:代理思路能否实现成用代理地址拉取,拉取到本地后重新修改成原地址。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
本地构建了镜像:docker.com/library/xxx:20240125,但是没有推到仓库里,然后pod的yaml 引用了这个镜像,拉取策略是IfNotPresent,这时候理论上本地有这个镜像,就不会再拉取,pod能正常启动,但是结果是镜像没正常启动,最后发现是Pod模板里面的镜像变成了docker.ketches.com/library/xxx:20240125。这个镜像由于没推到仓库,就拉取不到 我主要是碰到这个问题的时候我才看我们这个项目实现原理, 把yaml中的镜像替换为代理镜像,这样总感觉是修改了yaml文件的,为什么实现原理不是:用代理地址拉取到本地后修改为原来地址 |
@poneding @lakevilladom 很高兴能享受到第一个issue的喜悦,对于这个问题而言,如果需要把镜像拉下来重命名是超出了apiserver所能扩展的能力的,对于本地是否存在这个镜像apiserver也无法直接判断,这属于CRI部分。但是在这个示例中是不是没有正确配置需要代理的目标,一般而言我们只需要代理gcr等无法在国内正确访问的仓库。这是我个人的一些想法,等待作者给您一个完整的答复 |
如果想让 Pod 直接使用本地的镜像(拉取策略 IfNotPresent),当前的解决方法:
可能我后面还会再思考思考你这种场景的解决方法,谢谢~ |
@poneding 感谢你的回复! 总之感谢这个项目,让我不再为拉取镜像发愁,还顺便参考学习了cert-manager, sudo mkdir -p /etc/containerd/certs.d/docker.io
sudo sh -c 'cat >/etc/containerd/certs.d/docker.io/hosts.toml << EOF
server = "https://docker.io"
[host."https://dockerproxy.com"]
[host."https://mirror.baidubce.com"]
[host."https://docker.m.daocloud.io"]
[host."https://docker.nju.edu.cn"]
[host."https://docker.mirrors.sjtug.sjtu.edu.cn"]
[host."https://xxx.mirror.aliyuncs.com"]
capabilities = ["pull", "resolve"]
EOF'
sudo mkdir -p /etc/containerd/certs.d/gcr.io
sudo sh -c 'cat > /etc/containerd/certs.d/gcr.io/hosts.toml << EOF
server = "https://gcr.io"
[host."https://gcr.mirrors.ustc.edu.cn"]
[host."https://gcr.m.daocloud.io"]
[host."https://gcr.lank8s.cn"]
capabilities = ["pull", "resolve"]
EOF'
sudo mkdir -p /etc/containerd/certs.d/ghcr.io
sudo sh -c 'cat > /etc/containerd/certs.d/ghcr.io/hosts.toml << EOF
server = "https://ghcr.io"
[host."https://ghcr.lank8s.cn"]
capabilities = ["pull", "resolve"]
EOF'
sudo mkdir -p /etc/containerd/certs.d/k8s.gcr.io
sudo sh -c 'cat > /etc/containerd/certs.d/k8s.gcr.io/hosts.toml << EOF
server = "https://k8s.gcr.io"
[host."https://gcr.mirrors.ustc.edu.cn/google-containers/"]
[host."https://k8s-gcr.m.daocloud.io/"]
[host."https://registry.aliyuncs.com/k8sxio"]
[host."https://lank8s.cn/"]
[host."https://k8s.lank8s.cn"]
capabilities = ["pull", "resolve"]
EOF'
sudo mkdir -p /etc/containerd/certs.d/quay.io
sudo sh -c 'cat > /etc/containerd/certs.d/quay.io/hosts.toml << EOF
server = "https://quay.io"
[host."https://quay-mirror.qiniu.com"]
[host."https://quay.m.daocloud.io"]
[host."https://quay.mirrors.ustc.edu.cn"]
[host."https://quay.tencentcloudcr.com"]
capabilities = ["pull", "resolve"]
EOF'
sudo mkdir -p /etc/containerd/certs.d/registry.k8s.io
sudo sh -c 'cat > /etc/containerd/certs.d/registry.k8s.io/hosts.toml << EOF
server = "https://registry.k8s.io"
[host."https://lank8s.cn/"]
[host."https://registry.lank8s.cn/"]
[host."https://k8s.m.daocloud.io/"]
capabilities = ["pull", "resolve"]
EOF'
sudo mkdir -p /etc/containerd/certs.d/ghcr.io
sudo sh -c 'cat >/etc/containerd/certs.d/ghcr.io/hosts.toml << EOF
server = "https://ghcr.io"
[host."https://ghcr.lank8s.cn/"]
pabilities = ["pull", "resolve"]
EOF' |
这个只会修改pod的声明镜像,但并不会修改pod控制器(Deployment,Statefulset)中声明的镜像,所以我感觉这个还可以接受的。 |
场景:今天用Dockerfile构建了本地镜像(未推到Hub),拉取策略:IfNotPresent。本想直接引用本地镜像,但是pod一直报拉取失败,后来才发现镜像直接替换成了
docker.ketches.cn/xxx
.最后按照这个名称构建镜像后OK了问题:代理思路能否实现成用代理地址拉取,拉取到本地后重新修改成原地址。
The text was updated successfully, but these errors were encountered: