argocd-image-updater icon indicating copy to clipboard operation
argocd-image-updater copied to clipboard

ArgoCD Image Updater not updating tags in ApplicationSet

Open raviumishra opened this issue 1 year ago • 11 comments

ApplicationSet not updating new image tags from azure container registry

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
  metadata:
    name: hub-be
    namespace: dev-argocd-ns
  spec:
    generators:
      - list:
          elements:
            - cluster: dev
              url: [https://dev-aks-use.privatelink.eastus.azmk8s.io:443](https://dev-aks-use.privatelink.eastus.azmk8s.io/)
              namespace: dev-hub-be-ns
    template:
      metadata:
        name: '{{cluster}}-hub-be'
        annotations:
          argocd-image-updater.argoproj.io/image-list: dev=devaksuseACR.azurecr.io/helm/hub-be:*
          argocd-image-updater.argoproj.io/dev.pull-secret: pullsecret:dev-argocd-ns/argocd-image-updater-acr-secret
          argocd-image-updater.argoproj.io/dev.update-strategy: latest
          argocd-image-updater.argoproj.io/write-back-method: git:secret:dev-argocd-ns/argocd-image-updater-git-creds
          argocd-image-updater.argoproj.io/git-branch: feature/argocd
          argocd-image-updater.argoproj.io/dev.force-update: 'true'
      spec:
        project: hub
        source:
          repoURL: devaksuseacr.azurecr.io # ACR repo having OCI artifact
          "targetRevision": "1669"
          chart: helm/hub-be  # Name of the chart in the ACR
          helm:
            valueFiles:
              - values-dev.yaml
        destination:
          server: '{{url}}'
          namespace: '{{namespace}}'
        syncPolicy:
          automated:
            prune: true
            selfHeal: true
          syncOptions:
            CreateNamespace=true

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-image-updater-config
  namespace: dev-argocd-ns
data:
  log.level: debug
  registries.conf: |
    registries:
    - name: Azure Container Registry
      prefix: devaksuseACR.azurecr.io
      api_url: https://devaksuseACR.azurecr.io
      credentials: pullsecret:dev-argocd-ns/argocd-image-updater-acr-secret

Expected behavior targetRevision to be updated with new tag from Azure container registry in Bitbucket repo ApplicationSet YAML The current tag in ACR is : 0.1.0-rm-gnr1225.1-669 The current tag in repo YAML file is : 1668 The current tag used by argocd app : 0.1.0-GNR-1225.1-662

Version (argocd: v2.9.18+151ee6a)

Logs Logs attached Uploading argocd-image-updater.log… : Logs of AIU pod

raviumishra avatar Sep 10 '24 15:09 raviumishra

image

raviumishra avatar Sep 10 '24 15:09 raviumishra

Did you try setting git-repository annotation in the app template? If not, the application source repoURL is used as the git repository for git write-back. See https://argocd-image-updater.readthedocs.io/en/latest/basics/update-methods/#specifying-a-repository-when-using-a-helm-repository-in-repourl

chengfang avatar Sep 10 '24 20:09 chengfang

@chengfang I am using bitbucket username and app password argocd-image-updater.argoproj.io/git-repository: [email protected]:ravi_mishra_gp/argocd.git Do I specify anything under ConfigMap ?

This is the path where my ApplicationSet resides in repo. This YAML needs to be modified by AIU image

Currently using a bitbucket secret username:app password

apiVersion: v1
kind: Secret
metadata:
  name: argocd-image-updater-git-creds
  namespace: dev-argocd-ns
data:
  password: App password
  username: user name
type: Opaque

raviumishra avatar Sep 11 '24 02:09 raviumishra

@chengfang Please help me here. Tried both these versions : image image image image but the targetRevision of YAML was not updated as per the ACR image image image image

raviumishra avatar Sep 11 '24 05:09 raviumishra

argocd-image-updater does not update the helm chart version (targetRevision) in your application. It updates the image name and tag used by your applications, as listed in the image-list annotation.

chengfang avatar Sep 11 '24 19:09 chengfang

@chengfang are you saying that updater will not update my ApplicationSet yaml in repo ? The image details in my repo yaml image The image on my ACR image Image name and tag used by argocd app image image

raviumishra avatar Sep 11 '24 20:09 raviumishra

image updater will not update your applicationset yaml itself. By default it adds override parameters to the file .argocd-source-<appName>.yaml, and you can configure a custom write-back target such as helm values file. See https://argocd-image-updater.readthedocs.io/en/latest/basics/update-methods/#git-write-back-target

However, from last few lines in the above logs, the image is already up to date, so there will be no update needed.

chengfang avatar Sep 12 '24 01:09 chengfang

@chengfang As per the logs the image is up to date. But you can see that the latest image in ACR = 0.1.0-rm-gnr1225.1-673 while the one used by argocd app = 0.1.0-rm-gnr1225.1-672 I dont understand this

raviumishra avatar Sep 12 '24 02:09 raviumishra

from the logs, there seems exist a platforms annotation in your application, which filters out images with non-match platforms. If so, can you try removing the platforms annotation?

chengfang avatar Sep 12 '24 03:09 chengfang

@chengfang Cant find any such annotation in my AppSet yaml

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: hub-be
  namespace: dev-argocd-ns
spec:
  generators:
    - list:
        elements:
          - cluster: dev
            url: https://dev-aks-use.privatelink.eastus.azmk8s.io:443
            namespace: dev-hub-be-ns
  template:
    metadata:
      name: '{{cluster}}-hub-be'
      annotations:
        argocd-image-updater.argoproj.io/image-list: dev=devaksuseACR.azurecr.io/helm/hub-be:*
        argocd-image-updater.argoproj.io/dev.pull-secret: pullsecret:dev-argocd-ns/argocd-image-updater-acr-secret
        argocd-image-updater.argoproj.io/dev.update-strategy: latest
        argocd-image-updater.argoproj.io/git-repository: [email protected]:ravi_mishra_gp/argocd.git
        argocd-image-updater.argoproj.io/write-back-method: git:secret:dev-argocd-ns/argocd-image-updater-git-creds
        argocd-image-updater.argoproj.io/git-branch: feature/argocd
        argocd-image-updater.argoproj.io/dev.force-update: 'true'
    spec:
      project: hub
      source:
        repoURL: devaksuseacr.azurecr.io # ACR repo having OCI artifact
        targetRevision: 0.1.0-rm-gnr1225.1-674 # Chart version
        chart: helm/hub-be  # Name of the chart in the ACR
        helm:
          valueFiles:
            - values-dev.yaml
      destination:
        server: '{{url}}'
        namespace: '{{namespace}}'
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-image-updater-repo-cm
  namespace: dev-argocd-ns
data:
  repositories.conf: |
    repositories:
    - url: https://bitbucket.org/ravi_mishra_gp/repository.git
      credentials: secret:dev-argocd-ns/argocd-image-updater-git-creds
      imageUpdater:
        repositories:
          - name: devaksuseACR.azurecr.io/helm/hub-be
            tagPattern: "^v[0-9]+\\.[0-9]+\\.[0-9]+$"


raviumishra avatar Sep 12 '24 03:09 raviumishra

Cant find any such annotation in my AppSet yaml ok, that may be some default values.

In your argocd-image-updater-repo-cm configmap, you have tagPattern: "^v[0-9]+\\.[0-9]+\\.[0-9]+$", which may not match the image tag in your registry. This config map doesn't seem to be used, but want to point that out in case the same filtering is used elsewhere.

You may want to try other update strategies if they fit your workflow. The latest strategy requires fetching metadata of all image tags and the quality of these metadata may have influence here.

chengfang avatar Sep 13 '24 15:09 chengfang