How can I cache large docker images on new GKE nodes?

6/11/2020

When GKE creates a new node as part of its autoscaler, how can I ensure that this new node has fast access to a large docker image? One of the docker image size is 15GB and I have a deployment that uses that image. Would be nice to somehow cache this image onto new nodes so it doesn't have to be pulled every time a new node is launched!

-- crossvalidator
caching
docker
google-kubernetes-engine
kubernetes

1 Answer

6/12/2020

In such case I would recommend you to use Container Registry as there is no mean to make your image automatically available locally on newly created worker nodes (e.g. appearing as a result of node autoscaling process). If you decide not to use Container Registry, you would need to take care of uploading such image manually to every newly created node and this can be a tedious task.

Would be nice to somehow cache this image onto new nodes so it doesn't have to be pulled every time a new node is launched!

So unfortunatelly it does have to be pulled at least once when a new node is launched. It may be cached after that i.e. once it was pulled the first time from GCR.

As you can read here:

The default pull policy is IfNotPresent which causes the Kubelet to skip pulling an image if it already exists.

So you dont' have to do anythig specific to make sure your images are cached locally once they're already pulled as this is the default behaviour.

-- mario
Source: StackOverflow