Will Changing My Image Repository URL Force a Redeployment in Kubernetes?
Asked by
CuriousCoder92
I'm working with a StatefulSet setup for Redis and RabbitMQ using Bitnami's Helm charts, and I've set the imagePullPolicy to 'IfNotPresent'. I want to change the repository from Bitnami to Bitnami Archive, but the image content will remain the same (the MD5/hash is unchanged). Will Kubernetes recognize that there's no real change and keep the current image from the cache, or will it trigger a new image pull and force a redeployment of my application pods?
Answers
It seems like changing the repository name would be seen as a change, so it likely will trigger a redeployment. That's why it's a good idea to test in a lab environment firstโitโs often quicker than asking for help!
Reply to this answer
I doubt Kubernetes has the intelligence to avoid a rollout in this case. I think it will trigger a redeploy, but you might find the container runtime using the cached image.
Reply to this answer
If it changes the spec.template, itโll definitely cause a rollout since that alters the hash of the ReplicaSet. The only way I found to manage this is to set an onDelete strategy for the StatefulSet.
Reply to this answer
I found a workaround to avoid rollouts when CI changes image URLs from a local registry to GitLabโs. The good part is that Docker/containerd wonโt download images with the same digest again, but that might not prevent Kubernetes from rolling out new pods.
NewbieQuestion: So, if it won't redownload due to the same digest, will Kubernetes still force a rollout?
Reply to this answer
Changing the image tag, name, or repository definitely affects the pod template hash, which will trigger a redeployment or update in Kubernetes.
Reply to this answer
Add your answer
Answers are reviewed before publication.
LabRat123: I have a lab set up too, but this switch has already happened for me. The image is gone from the original repo, so I can't easily flip back to check how Kubernetes reacts.
CautiousDev: Iโd expect it to redownload, but luckily, everything should still be cached if the image is unchanged.