Disable Kubernetes pod update when container digest is same even if different image tag is given

1/6/2020

Let's say I have an image foo with tag v1. So I deployed it on Kubernetes by foo:v1.

However, for some reason(e.g. monoversion in monorepo), I pushed the exact same image to container registry with tag v2. And I changed k8s manifest to foo:v2.

In this situation, I want to update the pod only when the image digest of v1 and v2 are different. So in the case of foo, the digest are same, so container of foo:v1 should keep running.

Is this possible? If so, how?

Thanks

-- jjangga
deployment
docker
kubernetes
pod

1 Answer

1/6/2020

There is no way to update tag image without restarting pod. The only way to make it work is too use digest explicitly instead of tags.

So now image spec would look like this:

spec:
  image: foo@sha256:50cf965a6e08ec5784009d0fccb380fc479826b6e0e65684d9879170a9df8566

This way your image does not depended on tags. Digests can be found either on dockerhub or by running command docker images --digests <image-name>

-- acid_fuji
Source: StackOverflow