Ở các bài trước chúng ta đã sử dụng dependencies là task A chạy xong thì đến task B
Hôm nay chúng ta sẽ đi advance hơn về depends.
Nếu task A Succeeded thì mới chạy task B
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: name: wf-depends spec: entrypoint: dag-template arguments: parameters: - name: messageA value: A - name: messageB value: B templates: - name: dag-template inputs: parameters: - name: messageA - name: messageB dag: tasks: - name: Task1 arguments: parameters: [{name: text, value: "{{inputs.parameters.messageA}}"}] template: task-decision - name: TaskA template: task-a depends: Task1.Succeeded when: "{{tasks.Task1.outputs.result}} == A" - name: TaskB template: task-b depends: Task1.Succeeded when: "{{tasks.Task1.outputs.result}} == B" - name: TaskD template: task-d depends: TaskB.Skipped - name: task-decision inputs: parameters: - name: text script: image: python:3.8-slim command: source: | p = "{{inputs.parameters.text}}" print(p) - name: task-a script: image: python:3.8-slim command: source: | print("Task A was executed") - name: task-b script: image: python:3.8-slim command: source: | print("Task B was executed") - name: task-c script: image: python:3.8-slim command: source: | print("Task C was executed") - name: task-d script: image: python:3.8-slim command: source: | print("Task D was executed")
Bạn có thể thấy là TaskA sẽ chạy nếu task 1 Succeeded.
TaskD sẽ chạy khi mà taskB bị skip
Ngoài ra chúng ta còn các status result khác.
Tiếp đến Logic