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