Do multiple pods in Kubernetes pull the same image

10/14/2021

We need to scale up pods in our AKS Cluster. <be>

Somethimes we need to spin up so much, that multiple extra nodes are needed. <be>

Our docker image is 20GB big to pull. <br> (Yes I know its way to big, but it's impossible to reduce the size due being an older application.) <be>

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? Due the image is not cached. <be>

If they do, is there a way to prevent this? <be>

I prefer to have 4 pods waiting for pod 1 to download the image then downloading it 5 times.

-- Geert
azure-aks
docker
kubernetes

2 Answers

10/14/2021

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? 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.

If you want to make it quicker you can run 1 pod first and scale pods after that using command or HPA

-- Harsh Manvar
Source: StackOverflow

10/14/2021

Images are cached on the node to speedup new created pods on the same node.

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.

-- Mandraenke
Source: StackOverflow