关于模板输出的一些背景知识
Argo Workflows 支持多种不同的模板类型 https://github.com/argoproj/argo-workflows/blob/master/docs/workflow-concepts.md#template-types.
每种类型的模板支持不同类型的引用在模板内.
在一个steps
模板,您可以使用以下命令访问其他步骤的输出参数steps.step-name.outputs.parameters.param-name
(对于命名参数)或steps.step-name.outputs.result
(对于 a 的标准输出script
or container
模板)。
例子 (查看完整的工作流程 https://github.com/argoproj/argo-workflows/blob/master/examples/output-parameter.yaml):
- name: output-parameter
steps:
- - name: generate-parameter
template: whalesay
- - name: consume-parameter
template: print-message
arguments:
parameters:
- name: message
value: "{{steps.generate-parameter.outputs.parameters.hello-param}}"
在一个dag
模板,您可以使用类似的语法访问各种任务的输出,只需使用tasks.
代替steps.
.
例子 (查看完整的工作流程 https://github.com/argoproj/argo-workflows/blob/master/examples/dag-conditional-parameters.yaml):
- name: main
dag:
tasks:
- name: flip-coin
template: flip-coin
- name: heads
depends: flip-coin
template: heads
when: "{{tasks.flip-coin.outputs.result}} == heads"
- name: tails
depends: flip-coin
template: tails
when: "{{tasks.flip-coin.outputs.result}} == tails"
在一个container
or script
模板,您可以访问仅该模板的输入*。您不能直接从容器或脚本模板访问步骤或任务模板的步骤或任务的输出。
引用 DAG 的步骤输出
如上所述,DAG 模板无法直接引用来自steps
模板。但一步之内steps
模板可以将步骤输出传递到 DAG 模板.
在您的示例中,它看起来像这样:
templates:
- name: the-entrypoint
steps:
- - name: step01
template: first-step
- - name: step02
template: second-step
- - name: step03
template: third-step
- - name: step04-the-dag-step
template: fourth-step
arguments:
parameters:
- name: some-param
value: "{{steps.step03.outputs.result}}"
- name: fourth-step
inputs:
parameters:
- name: some-param
dag:
tasks:
# use the input parameter in the fourth-step template with "{{inputs.parameters.some-param}}"
tl;dr
steps.
and tasks.
变量的意思是在单个步骤或任务模板中引用,但它们可以明确地在模板之间传递。如果您需要使用 DAG 中某个步骤的输出,请直接将该输出作为调用 DAG 的参数传递。
在您的例子中,DAG 模板作为四个步骤的最后一个步骤被调用,因此您将在此处传递参数。
* Okay, you also have access to various other variables https://github.com/argoproj/argo-workflows/blob/master/docs/variables.md from within a script
or container
template, but you don't have access to variables that are scoped as internal variables within another template.