Removing specific images from all Kubernetes nodes

Nuno Aguiar
7 min readFeb 12, 2024

Remove or pull a single image from all Kubernetes nodes

Photo by Kurt Cotoaga on Unsplash

Have you ever used the wrong image on a Kubernetes cluster?
You have a corrected image on the registry but it has the same name and tag?
Are you trying to run on the cluster but some nodes have the old copy while others have the new copy?
You read about it online and then change the imagePullPolicy to ‘always’ but, among other issues, you get into the pull limits of the registry service?

You have tried searching for an easy way to replace the old images and it seems that there isn’t?

Well, you are not alone. Let me try to help with that.

Why it happens?

What you probably have already figure out is that each Kubernetes’ node has it’s own “cache” of container images. Each time a node needs one it will pull from the registry service a container image copy and keep it for as long as it’s used, to avoid filling the network with unneeded data transfers (e.g. that’s the default imagePullPolicy of ‘IfNotPresent’).

When you do have more that a few nodes and you have the wrong image this can become a nightmare.

What can be done?

--

--

Nuno Aguiar
Nuno Aguiar

Written by Nuno Aguiar

Senior Cloud Software Architect

Responses (1)