简体   繁体   English

如何将一个 WorkflowTemplate 的工件从 argo 中的工作流传递到另一个 WorkflowTemplate

[英]How to pass artifacts of one WorkflowTemplate to another WorkflowTemplate from a workflow in argo

I have a workflow template which outputs an artifact, this artifact has to be passed to another workflow template as an input.我有一个输出工件的工作流模板,该工件必须作为输入传递给另一个工作流模板。 how we can do that?我们怎样才能做到这一点? I'm following the way below which is not working我按照下面的方法行不通

Here is WorflowTemplate1.yaml这是WorflowTemplate1.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: arfile
spec:
  entrypoint: main
  templates:
    - name: main
      volumes:
        - name: vol
          emptyDir: {}
      inputs:
        parameters:

      script:
        image: "ubuntu"
        volumeMounts:
          - name: vol
            mountPath: "{{inputs.parameters.Odir}}"
        command: ["bash"]
        source: |
          #!/usr/bin/env bash
          echo "This is artifact testing" > /tmp/arfile

      outputs:
        parameters:
          - name: arfile
            path: "{{inputs.parameters.Odir}}/arfile"

Here is the WorkflowTemplate2.yaml这是WorkflowTemplate2.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: bfile
spec:
  entrypoint: main
  templates:
      - name: main
        volumes:
          - name: vol
            emptyDir: {}
        inputs:
          parameters:
            - name: image
              value: "ubuntu"
            - name: Odir
              value: "/tmp"
          artifacts:
            - name: arfile
              path: /tmp/arfile
        container:
          image: "ubuntu"
          command: ["cat"]
          args:
           - /tmp/arfile

Here is the workflow which is calling the above two workflow templates.I'm unable to pass artifacts of workflowtemplate1 to workflowtemplate2 from this workflow.这是调用上述两个工作流模板的工作流。我无法将 workflowtemplate1 的工件从此工作流传递到 workflowtemplate2。

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: apr-
spec:
  entrypoint: main
  templates:
    - name: main
      outputs:
        artifacts:
          - name: arfile
            from: "tasks['dfile'].outputs.artifacts.arfile"

      dag:
        tasks:
          - name: dfile
            templateRef:
              name: arfile
              template: main
            arguments:
              parameters:
                - name: bimg
                  value: "ubuntu"

          - name: bci
            depends: dfile
            templateRef:
              name: bfile
              template: main
            arguments:
              parameters:
                - name: img
                  value: "ubuntu"
              artifacts:
                - name: arfile
                  from: "{{tasks.dfile.outputs.artifacts.arfile}}"

What's wrong I'm doing here?我在这里做什么错了?

I think I found the issue.我想我发现了问题。 I need to use artifacts instead of parameters in WorkflowTemplate1.yaml in outputs code block我需要在输出代码块中使用artifacts而不是WorkflowTemplate1.yaml中的parameters

here's the fix这是解决办法

outputs:
  artifacts:
    - name: arfile
      path: "{{inputs.parameters.Odir}}/arfile"

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

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