aicoe-aiops / project-template

this is a template to use for new data science projects in the aiops group
Other
8 stars 21 forks source link

Add post sync workflow trigger #21

Closed tumido closed 3 years ago

tumido commented 3 years ago

Allow a post sync Argo CD hook via argocd.argoproj.io/hook: PostSync annotation. That would trigger the workflow after any manifests changes were applied by Argo CD. That means, in cases like, for example, we add a new notebook to the image and update the workflow to actually execute it, we can rerun the workflow automatically immediately the manifests changes are discovered and successfully applied by Argo CD.

This PR:

Be advised: Currently deployed Argo backend version (2.8.2) doesn't support workflowTemplateRef, once that is available the whole workflows can be simplified to:

kind: CronWorkflow
...
spec:
  ...
  workflowSpec:
    workflowTemplateRef:
      name: <CHANGE_ME>

compared to this bulky implementation here:

kind: CronWorkflow
...
spec:
  ...
  workflowSpec:
    entrypoint: entrypoint
    templates:
    - name: entrypoint
      steps:
      - - name: execute-template
          templateRef:
            name: <CHANGE_ME>
            template: entrypoint

Also note, the kustomizaton.yaml trick to support generateName in the hook manifest's metadata and scrub name the, comes from https://github.com/argoproj/argo-cd/issues/1639 . It allows the resources to be buildable via kustomize (name required) while allowing to generate name on the fly and not enforce it in the manifests (since that would allow only a single resource of that name present).