繁体   English   中英

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

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

我有一个输出工件的工作流模板,该工件必须作为输入传递给另一个工作流模板。 我们怎样才能做到这一点? 我按照下面的方法行不通

这是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"

这是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

这是调用上述两个工作流模板的工作流。我无法将 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}}"

我在这里做什么错了?

我想我发现了问题。 我需要在输出代码块中使用artifacts而不是WorkflowTemplate1.yaml中的parameters

这是解决办法

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

暂无
暂无

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

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