简体   繁体   English

在 Kubernetes 中做多个 pod 拉同一个镜像

[英]Do multiple pods in Kubernetes pull the same image

We need to scale up pods in our AKS Cluster.我们需要在我们的 AKS 集群中扩展 Pod。

Somethimes we need to spin up so much, that multiple extra nodes are needed.有时我们需要旋转太多,以至于需要多个额外的节点。

Our docker image is 20GB big to pull.我们的 docker 镜像需要 20GB 大。
(Yes I know its way to big, but it's impossible to reduce the size due being an older application.) (是的,我知道它变大的方式,但由于是一个较旧的应用程序,不可能减小大小。)

But I'm wondering if we spin up 5 new pods on 1 new node, do they all 5 start pulling the 20GB image at startup?但是我想知道我们是否在 1 个新节点上启动了 5 个新 pod,它们 5 个是否在启动时都开始提取 20GB 映像? Due the image is not cached.由于图像未缓存。

If they do, is there a way to prevent this?如果他们这样做,有没有办法防止这种情况?

I prefer to have 4 pods waiting for pod 1 to download the image then downloading it 5 times.我更喜欢让 4 个 pod 等待 pod 1 下载图像,然后下载 5 次。

Images are cached on the node to speedup new created pods on the same node.图像缓存在节点上以加速同一节点上新创建的 pod。

A very simple way to prevent that would be starting one pod per node at first and then scaling it up so the container runtime can reuse the previously pulled image.一种非常简单的防止这种情况的方法是首先为每个节点启动一个 pod,然后将其扩展,以便容器运行时可以重用之前提取的映像。

But I'm wondering if we spin up 5 new pods on 1 new node, do they all 5 start pulling the 20GB image at startup?但是我想知道我们是否在 1 个新节点上启动了 5 个新 pod,它们 5 个是否在启动时都开始提取 20GB 映像? Due the image is not cached.由于图像未缓存。

image being cache on Node they won't start maybe pulling the image each time.图像被缓存在节点上,他们可能不会每次都开始拉图像。

If they do, is there a way to prevent this?如果他们这样做,有没有办法防止这种情况?

if you don't want to cache and each time want to pull image you can use the imagepullpolicy : always in your YAML config.如果您不想缓存并且每次都想拉取图像,您可以使用imagepullpolicy : always在您的 YAML 配置中。

If you want to make it quicker you can run 1 pod first and scale pods after that using command or HPA如果你想让它更快,你可以先运行 1 个 pod,然后使用命令或 HPA 扩展 pod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM