Can please give me an example how to use PostSync hook ? #5680
Replies: 3 comments
-
Hi @IamGabrielWu, I'm not sure I 100% follow the first part of your question, but the Job (with hooks) should be contained alongside your other Helm resources in your Git repository, and will be automatically be created (and thus executed) once the Sync succeeds. (I presume you saw this). For the second part of your question, AFAICT you can't get who triggered the sync, but you can get some information about the application: The call to Helm will include environment variables containing application information: Which can be substituted as parameters into the Helm call: And from there you can use Helm templating of the Job (using those values) to include that information. |
Beta Was this translation helpful? Give feedback.
-
@jgwest i went through lots of materials on internet and still feel lost for what i can do to "contained alongside your other Helm resources in your Git repository,". Does it mean like this ? Please see my code below.
|
Beta Was this translation helpful? Give feedback.
-
App of appsI think the first half of your example will produce an app of apps where multiple Argo CD Applications (the generated Applications in the first half of your example) are contained within a single Argo CD Application (the parent app that will point to this repo in Argo CD). However, if you're doing that, the Job should NOT be included with the app of apps (eg, in this example, alongside the templated resources), it should be included within the Git repos of the individual apps themselves. Eg, for each application, it should be contained within these repos:
You CAN embed Job resources within an app of apps, and it will trigger whenever an app of apps syncs, but it won't get you the information you were looking for in your original question. (I would also point you to the Argo CD Example Apps repo if you haven't already looked at it) HelmOTOH, I think you mentioned that you were installing the Argo CD Applications to the cluster via Helm? In which case, again, the Job shouldn't be part of that Helm chart, it needs to be in repos pointed to by the source.path, source.repoURL, and source.targetRevision fields of the defined Application. |
Beta Was this translation helpful? Give feedback.
-
I'm using helm to create argocd applications and then deploy the applications into cluster.
I created a job as below, but i don't know how to configure application so that it knows the PostSync and when a sync operation succeeds, the postSync can be triggered.
And also btw, within the Job, is it possible to get who trigger the sync or what application is synced ?
Beta Was this translation helpful? Give feedback.
All reactions