argoproj-labs / argocd-image-updater

Automatic container image update for Argo CD
https://argocd-image-updater.readthedocs.io/en/stable/
Apache License 2.0
1.28k stars 263 forks source link

Argo CD Image Updater causes an infinite loop of syncs with ApplicationSets #400

Open RiverPhillips opened 2 years ago

RiverPhillips commented 2 years ago

Describe the bug I am using ApplicationSets to deploy multiple applications, the template for this ApplicationSet is creating applications with the required annotations for the image updater. This leads to the applications syncing constantly.

I cannot use git writeback as I want to ensure the image tagged main is always deployed.

To Reproduce Steps to reproduce the behaviour:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: name
  namespace: argocd
spec:
  generators:
  - git:
      directories:
      - path: manifests/*/overlays/dev
      repoURL: git@github.com:org/repo.git
      revision: HEAD
  template:
    metadata:
      annotations:
        argocd-image-updater.argoproj.io/image-list: app=foo:main
        argocd-image-updater.argoproj.io/app.update-strategy: digest
      name: '{{path[1]}}'
    spec:
      destination:
        namespace: name
        server: https://kubernetes.default.svc/
      project: project
      source:
        path: '{{path}}'
        repoURL: git@github.com:org/repo.git
        targetRevision: HEAD

Expected behaviour When the image digest changes there should be a sync, but this should not be an infinite loop.

Version Argo CD: v2.3.1 Argo CD Image Updater: v 0.11.3

jannfis commented 2 years ago

I'm afraid that the only way to use Image Updater in combination with ApplicationSet is to use Git write-back. If you use the argocd write-back method, the Image Updater will modify .spec.source of the Application in the cluster, which in turn gets overwritten by ApplicationSet controller again, leading to the situation you are observing.

This behavior most likely needs to change in ApplicationSet controller.

sali2801 commented 1 year ago

what about if you add write-back-method. From the doc:

As a rule of thumb, if you are managing Application in Git (i.e. in an app-of-apps setup), you most likely want to chose the Git write-back method.

tback commented 1 year ago

It'd be really great if you'd mention this in the documentation (in the "Limitations" section maybe?). It would have saved me a lot of time.

h3rmanj commented 5 days ago

For anyone hitting this, it seems to work without git write-back by using ignoreApplicationDifferences in the ApplicationSet. With kustomize this worked for me:

kind: ApplicationSet
spec:
  ignoreApplicationDifferences:
    - jsonPointers:
        - /spec/source/kustomize/images

I'm using the pull request generator, and ending up with a bunch of .argocd-source-<app+branchname>.yaml files wasn't really something I wanted.

chengfang commented 5 days ago

Another solution is to modify Argo CD applicationset controller policy. See https://github.com/argoproj-labs/argocd-image-updater/issues/186#issuecomment-1674705200