7

Using ArgoCD, I'd like to have the App AutoSync Update/Reploy when the docker image is updated on a specific tag such as latest or stable.

For example, if I have a deployment in my git repo like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: k8s-nginx-example
spec:
  selector:
    matchLabels:
      app: k8s-nginx-example
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: k8s-nginx-example
    spec:
      containers:
      - name: nginx
        image: my-repo/k8s-nginx-example:latest
        ports:
        - containerPort: 80
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi"
            cpu: "500m"

I'd like ArgoCD to update the deployment when a new docker image is pushed to latest tag or stable... etc. I know that ArgoCD polls the git repo of the app every 3 seconds so it is not aware of the changes to the Docker Image Tag. Another option could be (but I'm not sure how to do it) would be to have ArgoCD Update via a webhook that notifies ArgoCD that there is a new image to pull with the latest tag, although even after pushing a Docker Image to the repository with the latest and then manually syncing the app in ArgoCD, Argo does nothing. I suspect that Argo is only reaching out to the git repo to check for changes and is not concerned with the Docker image in the deployment.

The only way I can think of doing this currently with ArgoCD is to version the Docker images with version tags 1.2.3 and then script the build process to update the deployment in the git repository with the image tag version each time.

...
containers:
  - name: nginx
    image: my-repo/k8s-nginx-example:1.2.3
    ports:
...

Is there a way to do this in ArgoCD? Or would a better option be using Argo Workflows with Argo Events? I was hoping that there might be a plugin or something that can either trigger the event or monitor the docker image.

Thanks

Meta: Need tags Argo and ArgoCD

1
  • 1
    See our approach here - itnext.io/… . Currently we use slightly updated approach which works on pure manifests with no need for extra templating language (going to document updates soon). If you'd like to implement this, feel free to join discord discord.gg/UTxjBf9juQ - will help with implementation.
    – taleodor
    Commented May 3, 2021 at 0:42

2 Answers 2

8

This isn't really an ArgoCD thing. Keel is a good tool to help keep your images updated across the cluster and is super easy to implement. Basically, you'd just add some annotations to your manifest.

metadata:
  annotations:
    keel.sh/policy: force
    keel.sh/trigger: poll      
    keel.sh/pollSchedule: "@every 10m"

It may be worth noting that if you are moving to run this in production, avoid the use of the latest tag. This is considered bad practice as it can burn you when breaking changes are pushed. Keel can handle that through an innate understanding of semver tags allowing you to update on minor version changes, but avoid major without testing, etc.

2
  • 1
    I agree. I think I may have to just implement a system to auto push versions to the deployments
    – DogEatDog
    Commented May 4, 2021 at 14:53
  • 2
    Check out Keel before you re-build it. It is super light and may save you a bit. Plus, you get a log of what keel has done to push this. Of course, you may prefer the audit trail in your infra git repo be explicit instead of managing permissions as tightly against the container repo. If that's the case though, consider if this is a bottle neck on your CD time.
    – Josiah
    Commented May 4, 2021 at 14:57
4

The canonical, ArgoCD-native way to do so is to use the ArgoCD image updater.

It is currently being mainlined:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.