我有下面提到的Argo DAG样本。如下所示,我对每个任务的参数值进行了硬编码。每个任务使用不同的参数值。我知道Argo提供了一种以JSON或YAML格式提交参数文件以动态传递参数值的方法。然而,我想知道是否有一种方法可以通过参数文件为下面DAG中的每个任务传递不同的值。
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: dag-diamond-custom-
spec:
entrypoint: diamond
templates:
- name: echo
retryStrategy:
limit: 3
inputs:
parameters:
- name: message
- name: task
container:
image: index_ruby:latest
imagePullPolicy: Never
command: [ruby, "index.rb", "-s" , "{{inputs.parameters.task}}" , "-r", "{{inputs.parameters.message}}"]
- name: diamond
dag:
tasks:
- name: A
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueA"}
- name: task
value: A
- name: B
dependencies: [A]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueB"}
- name: task
value: B
- name: C
dependencies: [A]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueC"}
- name: task
value: C
- name: D
dependencies: [B, C]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueD"}
- name: task
value: D
Argo工作流规范包括arguments
,其中可以定义许多全局参数。
您可以为每个任务定义一个参数,然后通过模板访问它。
(我修改了echo
容器一点,因为我在Ruby映像方面遇到了问题。(
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: dag-diamond-custom-
spec:
entrypoint: diamond
arguments:
parameters:
- name: valueA
- name: valueB
- name: valueC
- name: valueD
templates:
- name: echo
retryStrategy:
limit: 3
inputs:
parameters:
- name: message
- name: task
container:
image: docker/whalesay:latest
command: [echo]
args: ["{{inputs.parameters.task}}", "{{inputs.parameters.message}}"]
- name: diamond
dag:
tasks:
- name: A
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "{{workflow.parameters.valueA}}"}
- name: task
value: A
- name: B
dependencies: [A]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "{{workflow.parameters.valueB}}"}
- name: task
value: B
- name: C
dependencies: [A]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "{{workflow.parameters.valueC}}"}
- name: task
value: C
- name: D
dependencies: [B, C]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "{{workflow.parameters.valueD}}"}
- name: task
value: D
正如您所提到的,您可以创建一个参数的JSON文件。。。
{
"valueA": 1,
"valueB": 2,
"valueC": 3,
"valueD": 4
}
然后通过CCD_ 3传递来自文件的参数。
argo submit workflow.yaml -f params.json --watch