'Argo workflow: schedule once at a specific time
I want to trigger an Argo workflow to start running at a specific time. I am currently using a workflowTemplate and the rest API to submit
a workflow with this template. Is there a way to tell Argo to start the workflow at a specific time.
I am aware of the existence of cron-workflow and cron-workflow-template. But I am not able to figure out how to use either workflow or cron-workflow to achieve what I want.
To have any scheduling, do I must use cron-workflow? Or is there a way to trigger a regular workflow at a delay by passing the schedule-time in submitOptions or in some other way through the rest API?
If I must use cron workflow, what should I set the schedule value at? I don't want it to run automatically or periodically, but only when I want and at a specific time. Is there a way achieve that using cronWorkflowTemplate and the rest API?
I will appreciate any help/pointers.
Solution 1:[1]
Likely not the answer you're looking for, but if you are able to alter your WorkflowTemplate, you can make the first step be an immediate suspend step, with a value that is provided as an input (by you, when deciding you want to submit the workflow, just not now). For instance, your workflow may look something like this:
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: my-workflow-template
spec:
entrypoint: my-wf
arguments:
parameters:
- name: wait-time-sec
value: "0" # override me
templates:
- name: my-wf
inputs:
parameters:
- name: wait-time-sec
steps:
- - name: wait
template: wait-template
arguments:
parameters:
- name: wait-time-sec
value: "{{inputs.parameters.wait-time-sec}}"
- - name: rest of original workflow steps...
- name: wait-template
inputs:
parameters:
- name: wait-time-sec
suspend:
duration: "{{inputs.parameters.wait-time-sec}}"
...
When you want to submit it, just pass in the parameter wait-time-sec
. Granted, if you would rather have a specific time, you would either have to calculate how many seconds that would be before submitting, or write a simple script before the wait
step to do that calculation for you, taking in an input of a datetime and outputting seconds for the wait
step to use.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | tubensandwich |