ArgoCD: run a specific pipeline after a specific succesful ArgoCD deploy

182 views Asked by At

We use ArgoCD Applications to deploy a set of Kubernetes resources. How can I start a specific pipeline after a specific succesful Application run?

First I thought that starting such a pipeline could be done from an ArgoCD PostSync. As I understand now, a PostSync is a general hook, not a specific hook for 1 ArgoCD application. Correct?

Let me simplify my question. I have 2 ArgoCD applications. I want to execute action 1 (eg start a pipeline 1) after a successful sync of application 1. And action 2 only after a successful sync of application 2. How can I specify that?

Applications:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: app1
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/app1repo/apps-1.git
    targetRevision: HEAD
    path: app1path
  destination:
    server: https://kubernetes.default.svc
    namespace: app1

And Application2:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: app2
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/app2repo/apps-2.git
    targetRevision: HEAD
    path: app2path
  destination:
    server: https://kubernetes.default.svc
    namespace: app2

Action 1 should only be done after the succesfull sync of Application1:

apiVersion: batch/v1
kind: Job
metadata:
  generateName: app-slack-notification-
  annotations:
    argocd.argoproj.io/hook: PostSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      containers:
      - name: app1-post-sync
        image: busybox
        command: ["echo", "This simulates an **app1** post sync action"]
      restartPolicy: Never

And action 2 after the succesfull sync of Application2:

apiVersion: batch/v1
kind: Job
metadata:
  generateName: app-slack-notification-
  annotations:
    argocd.argoproj.io/hook: PostSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      containers:
      - name: app2-post-sync
        image: busybox
        command: ["echo", "This simulates an **app2** post sync action"]
      restartPolicy: Never
1

There are 1 answers

0
tm1701 On BEST ANSWER

Just put the PostSync config files in the Helm chart.

When the Application updates, the PostSync is done as described in the Helm chart of the Application.