【问题标题】:How to access the outputs in a workflow which are generated in another workflow template in argo如何访问在 argo 的另一个工作流模板中生成的工作流中的输出
【发布时间】:2022-01-21 13:52:07
【问题描述】:

我需要将 Argo 输出传递回在另一个工作流模板中生成的工作流

所以我有一个名为A 的工作流和两个名为BC 的工作流模板

当我运行我的 Workflow A 时,它会调用 WorkflowTemplate B,然后 B 会调用另一个 WorkflowTemplate C

触发流程是这样的A -> B -> c

现在 WorkflowTemplate C 将输出作为工件生成。我想将这些输出传递回 WorkflowTemplate B,并且应该将它们传递回 Workflow A。这样我就可以将该输出用作同一工作流中另一个任务的输入A

输出通过流应该像C -> B -> A

argo 工作流程中是否有任何方法可以做到这一点?你能给我举个例子吗?

【问题讨论】:

  • A如何调用B,B如何调用C?通过templateRefworkflowTemplateRef?或者可能使用resource 模板?
  • @crenshaw-dev 他们使用templateRef调用

标签: workflow argo-workflows argo


【解决方案1】:

通过 templateRef 从另一个 WorkflowTemplate 调用模板与通过 template 从同一 Workflow 调用模板完全相同。

(注:我写了post on differentiating uses of the word "template" in Argo Workflows。)

这是一个改编自artifact passing example的示例:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: templates
spec:
  templates:
  - name: whalesay
    container:
      image: docker/whalesay:latest
      command: [sh, -c]
      args: ["cowsay hello world | tee /tmp/hello_world.txt"]
    outputs:
      artifacts:
      - name: hello-art
        path: /tmp/hello_world.txt
  - name: print-message
    inputs:
      artifacts:
      - name: message
        path: /tmp/message
    container:
      image: alpine:latest
      command: [sh, -c]
      args: ["cat /tmp/message"]
---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: artifact-passing-
spec:
  entrypoint: artifact-example
  templates:
  - name: artifact-example
    steps:
    - - name: generate-artifact
        templateRef:
          name: templates
          template: whalesay
    - - name: consume-artifact
        templateRef: 
          name: templates
          template: print-message
        arguments:
          artifacts:
          - name: message
            from: "{{steps.generate-artifact.outputs.artifacts.hello-art}}"

【讨论】:

  • 它不适用于多个工作流模板。让我用我创建的模板发布一个新问题
  • 发表了另一个问题 - stackoverflow.com/questions/70897648/… 请你看一下吗?我已经发布了我为传递输出创建的工作流模板和工作流
猜你喜欢
  • 2022-07-07
  • 2022-01-26
  • 2022-08-16
  • 2023-01-11
  • 2021-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-16
相关资源
最近更新 更多