<p>I frequently update a Docker image using the same tag on Azure Container Registry. I would like to automatically run a rolling update when a new tag is pushed to my ACR, so pods are automatically updated with the latest version of the image.</p>
<p>ACR provides a Webhook feature to automatically call a webhook when a new tag is pushed.</p>
<p>My first approach would be to create webhook in Kubernetes exposed through an ingress and callable from the ACR. The webhook would perfom the rolling update, but it requires to access the Kubernetes API.</p>
<p>Is it possible? Am I in the right direction, or is there a more convenient way to answer my requirement?</p>
<p>Thanks!</p>

<p>Yes, it's possible. If ACR can call a webhook whenever a new image is pushed (even with the same tag), you can call a webhook service in your cluster. The service can then, for example, update an annotation in the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#podtemplatespec-v1-core" rel="nofollow noreferrer">PodTemplateSpec</a> of your Deployment, which triggers a rolling update of your Pods.</p>
<p>However, it requires that the <a href="https://kubernetes.io/docs/concepts/containers/images/#updating-images" rel="nofollow noreferrer">imagePullPolicy</a> of the containers is set to Always, as the tag of the image remains unchanged. Otherwise, Kubernetes would think that it's still the same image and would use the one that it has previously pulled.</p>
<p>For access to the Kubernetes API, you can do this with a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/" rel="nofollow noreferrer">ServiceAccount</a> to which you assign the necessary Kubernetes API permissions with <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">Roles and RoleBindings</a>. Finally, you assign this ServiceAccount to your Pods through the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#podspec-v1-core" rel="nofollow noreferrer"><code>serviceAccountName</code></a> field in the PodSpec.</p>
