是否可以选择在Kubernetes群集中的节点之间复制图像?
我有一种情况,我们必须在K8S节点中修补Docker映像并重新启动以启动旧图像。这个过程并不是那么容易和显而易见,因为我有几个节点。
因此,我可以仅在一个节点上进行retag进程,然后将新图像复制到其他节点吗?如果有可能这样做,那么我是否应该在复制重新编写一个图像之前删除旧图像?
I have a case where we have to patch the docker image in k8s node and retag it to start over the old one. This process ain't so easy and obvious, because I have several nodes.
Therefore, could I do retag process only on one node and then copy a new image to other nodes? If there is a possibility to do so, then should I delete the old image before copying retagged one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最佳实践:
此外,您可以创建一个私人回购注册表并从那里推动/推出docker映像。
因此,请更改图像,推向回购,现在所有节点都可以拉出新图像。
ref: 在Ubuntu 18.04上设置私人码头注册表
否之前删除旧图像,请使用图像版本。
假设您正在使用Image myimage:1.1 ,现在您进行了一些更改并使用版本1.2创建新图像,因此您的图像将为 myimage:1.2
现在在部署文件中,将您的图像名称更改为 myimage:1.2 ,然后创建部署。现在,您的部署将通过新图像进行升级。
您可以使用滚动更新停机时间。
道德:
在新的IT世界中,我们主要在多个群集中工作。根据客户的需求或业务满足,我们会定期更改或自定义。我们不能只做单节点,然后将其推向每个人1-1,相信我非常忙。
Best Practice:
Moreover you can create a private repo registry and push/pull your docker images from there.
So make change in your image, push to repo, now all nodes will able to pull the new image.
Ref: Setting Up a Private Docker Registry on Ubuntu 18.04
No, use image versioning.
Lets assume you are using image MyImage:1.1, now you make some changes and create new image with version 1.2, so your image will be MyImage:1.2
Now in your deployment file, change your image name to MyImage:1.2, and create the deployment. Now your deployment will upgraded with new image.
You can use Rolling Update for the upgrade strategy for zero downtime.
Moral :
In new IT world, we mostly work in multiple clusters with many nodes. We have regular changes or customization as per the client demand or business met. We cant just make change in single node and then pushing it to everyone 1-1, trust me it is very hectic.
我建议您克隆您的部署并将您的重新映像用于新节点,并使用旧的图像标签缩小旧部署。
LP
I advise you to clone your deployement and use your retaged image for your new nodes, and scale down the old deployement with the old image tag.
LP
不可能将群集进行集群复制。您需要使用kubectl cp在本地复制它,然后将文件复制回:
kubectl cp:/tmp/test/tmp/test
kubectl cp/tmp/test:/tmp/test
如果要共享文件下注,nx4weew pods,并且只有一个豆荚需要写入访问,则可能要在多个豆荚上安装一个ro量,或者使用像s3这样的对象存储。往返于Pod的文件确实不应该是您经常做的事情,这是一个反图案。
It's not possible to do cluster to cluster copying. You'd need to use kubectl cp to copy it locally, then copy the file back:
kubectl cp :/tmp/test /tmp/test
kubectl cp /tmp/test :/tmp/test
If you are trying to share files bet,nx4ween pods, and only one pods needs write access, you probably want to mount an ro volume on multiple pods, or use an object store like S3. Copying files to and from pods really shouldn't be something you're doing often, that's an anti-pattern.