We have a system that currently uses docker-compose for deployment of containers (effectively docker-compose pull && docker-compose up) and are in the process of converting the system to Kubernetes.
We have CI/CD that deploys to production automatically based on git tags pushed to the git repository. For staging, we keeping advancing a branch. The docker images are built and tagged with either the git production tag or git staging branch name.
At deployment, docker-compose is intelligent enough to not restart the container if the image is actually the same, i.e. two production tags point to the same image.
I'm looking for a way to do the same thing in Kubernetes - if at deployment the actual image used for the container of the pod is the same as what's already running (based on the image checksum, not just the image tag), then it shouldn't have to restart the pod. Is this possible?
Thanks
imagePullPolicysetting? According to documentation if theimagePullPolicyis set toIfNotPresent, it should tell the kubelet to skip pulling an image if it already exists, so the pod shouldn't be restarded.Always. I thought theIfNotPresentbehaviour would be "I already have an image with this tag, so I won't pull". So, as the same tag is always moving to a new image, I thought it wouldn't pull. I guess I'll just have to try it...!Alwaysimage policy,the kubelet queries the container image registry to resolve the name to an image digest. If the kubelet has a container image with that exact digest cached locally, the kubelet uses its cached image; otherwise, the kubelet download the image with the resolved digest, and uses that image to launch the container.