<p>I am trying to setup CI using Azure DevOps and CD using GitOps for my AKS cluster. When CI completes the image is pushed to Azure Container Registry. My issue is the name of the image in my yaml file is :latest. When I push the image to container registry, Flux CD is not able to determine if there are any changes to the image or not because the name of the image remains same. I tried to look up the issue in github and came up with the below link:
<a href="https://github.com/GoogleCloudPlatform/cloud-builders/issues/22#issuecomment-316181326" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/cloud-builders/issues/22#issuecomment-316181326</a>
But I dont know how to implement it. Can someone please help me?</p>

<p>From the docs of FluxCD <a href="https://docs.fluxcd.io/en/1.18.0/references/automated-image-update.html#automated-deployment-of-new-container-images" rel="nofollow noreferrer">here</a></p>
<blockquote>
<p>Note: that Flux only works with immutable image tags (:latest is not
supported). Every image tag must be unique, for this you can use the
Git commit SHA or semver when tagging images.</p>
</blockquote>
<p>Turn on automation based on timestamp:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    fluxcd.io/automated: &quot;true&quot;
spec:
  template:
    spec:
      containers:
      - name: app
        image: docker.io/org/my-app:1.0.0
</code></pre>
<p>The above configuration will make Flux update the app container when you push a new image tag, be it my-app:1.0.1 or my-app:9e3bdaf.</p>
<p>Restrict image updates with sem ver:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    fluxcd.io/automated: &quot;true&quot;
    fluxcd.io/tag.app: semver:~1.0
spec:
  template:
    spec:
      containers:
      - name: app
        image: docker.io/org/my-app:1.0.0
</code></pre>
<p>The above configuration will make Flux update the image when you push an image tag that matches the semantic version expression e.g my-app:1.0.1 but not my-app:1.2.0</p>
<p>You should use Git commit SHA or semver when tagging images in azure DevOps Pipeline <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker?view=azure-devops" rel="nofollow noreferrer">docker task</a></p>
<pre><code>steps:
- task: Docker@2
  displayName: Build and Push
  inputs:
    command: buildAndPush
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: |
      tag1
      tag2
</code></pre>
