简体   繁体   English

如何访问在 argo 的另一个工作流模板中生成的工作流中的输出

[英]How to access the outputs in a workflow which are generated in another workflow template in argo

I've a requirement to pass the Argo outputs back to workflow which are generated in a another workflow template我需要将 Argo 输出传递回在另一个工作流模板中生成的工作流

So I have ONE Workflow called A and TWO WorkflowTemplates called B and C所以我有一个名为A工作流程和两个名为BC的工作流程模板

When I run my Workflow A it invokes WorkflowTemplate B and then B invokes another WorkflowTemplate C当我运行我的 Workflow A时,它调用 WorkflowTemplate B ,然后B调用另一个 WorkflowTemplate C

The trigger flow is like this A -> B -> c触发流程是这样A -> B -> c

Now the WorkflowTemplate C produces the outputs as an artifact.现在 WorkflowTemplate C将输出作为工件生成。 I want to pass these outputs back to WorkflowTemplate B and the same should be passed back to Workflow A .我想将这些输出传递回 WorkflowTemplate B并且应该将它们传递回 Workflow A So that I can use that output as an input to another task in the same Workflow A这样我就可以使用 output 作为同一工作流A中另一个任务的输入

The outputs passing flow should be like C -> B -> A输出通过流应该像C -> B -> A

Is there any way in argo workflows to do this? argo 工作流程中有什么方法可以做到这一点吗? Can you point me to an example?你能给我举个例子吗?

Invoking a template from another WorkflowTemplate via templateRef works precisely the same as invoking a template from the same Workflow via template .通过 templateRef 从另一个 WorkflowTemplate 调用模板与通过templateRef从同一个 Workflow 调用template完全相同。

(Note: I wrote a post on differentiating uses of the word "template" in Argo Workflows .) (注意:我写了一篇关于区分 Argo Workflows 中“模板”一词的用法的帖子。)

Here's an example adapted from the 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}}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM