Bạn sẽ cần lập lịch chạy 1 vài flow và argo cũng sẽ hỗ trợ bạn
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: cronwf-dag
spec:
schedule: "0 2 * * *"
concurrentcyPolicy: "Forbid"
startingDeadLineSeconds: 70
workflowSpec:
entrypoint: dag-templates
templates:
- name: dag-templates
dag:
tasks:
- name: Task1
template: task-template
- name: Task2
template: task-template
dependencies: [Task1]
- name: Task3
template: task-template
dependencies: [Task1]
- name: Task4
template: task-template
dependencies: [Task2, Task3]
- name: task-template
script:
image: python:3.8-slim
command:
source: |
print("Nimtechnology - Task executed.")
Chúng ta cùng tìm hiểu 1 chút về pipeline trên.
concurrentcyPolicy: “Forbid” cái này nghĩa là không cho các job chạy đồng thời khi job A chưa xong thì chưa chạy job B ==> nó kiểu như là crontab của là 1 phút chạy 1 lần, nhưng mà job của bạn 2 phút để complete thì nó sẽ chờ job đó chạy xong mới start job mới
StartingDeadlineSeconds is a field in CronWorkflow that specifies the maximum amount of time in seconds that a CronWorkflow can wait for a job to start before it is considered failed. This field is optional, and if it is not specified, the CronWorkflow will wait indefinitely for the job to start.
For example, suppose you have a CronWorkflow that is scheduled to run every hour and triggers a Kubernetes Job. If the StartingDeadlineSeconds field is set to 3600 (1 hour), the CronWorkflow will wait for up to one hour for the Job to start. If the Job has not started within this time frame, the CronWorkflow will be considered failed and will not trigger the Job.
Here is an example of a CronWorkflow YAML manifest that includes the StartingDeadlineSeconds field:
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: example-cron
spec:
startingDeadlineSeconds: 1800
schedule: "*/30 * * * *"
workflowSpec:
entrypoint: my-workflow
templates:
- name: my-workflow
container:
image: my-image
command: ["/bin/sh"]
args: ["-c", "echo Hello World"]
In this example, the CronWorkflow is scheduled to run every 30 minutes (*/30 * * * *) and has a startingDeadlineSeconds value of 1800 (30 minutes). If the Kubernetes Job triggered by this CronWorkflow does not start within 30 minutes, the CronWorkflow will be considered failed.
Bạn có thể thao khảo bài này để hiểu thêm về nhiều option.