全部產品
Search
文件中心

Container Service for Kubernetes:配置Artifacts

更新時間:Feb 28, 2024

通過配置使用工作流程叢集Artifacts,可以在工作流程各個步驟之間傳遞參數,一個步驟的輸出可以作為另一個步驟的輸入,從而完成複雜工作流程步驟的編排。本文介紹如何使用阿里雲OSS作為Artifacts的儲存,在工作流程步驟間傳遞參數。

前提條件

已開通阿里雲Object Storage Service服務。具體操作,請參見開通OSS服務

操作步驟

  1. 配置阿里雲OSS。具體操作,請參見Configuring Alibaba Cloud OSS

  2. 使用以下YAML內容,建立artifect-passing.yaml檔案。

    apiVersion: argoproj.io/v1alpha1
    kind: Workflow
    metadata:
      generateName: artifact-passing-
    spec:
      entrypoint: artifact-example
      templates:
      - name: artifact-example
        steps:
        - - name: generate-artifact
            template: whalesay
        - - name: consume-artifact
            template: print-message
            arguments:
              artifacts:
              # bind message to the hello-art artifact.
              # generated by the generate-artifact step.
              - name: message
                from: "{{steps.generate-artifact.outputs.artifacts.hello-art}}"
    
      - name: whalesay
        container:
          image: docker/whalesay:latest
          command: [sh, -c]
          args: ["cowsay hello world | tee /tmp/hello_world.txt"]
        outputs:
          artifacts:
          # generate hello-art artifact from /tmp/hello_world.txt.
          # artifacts can be directories as well as files.
          - name: hello-art
            path: /tmp/hello_world.txt
    
      - name: print-message
        inputs:
          artifacts:
          # unpack the message input artifact.
          # and put it at /tmp/message.
          - name: message
            path: /tmp/message
        container:
          image: alpine:latest
          command: [sh, -c]
          args: ["cat /tmp/message"]
  3. 執行以下命令,提交工作流程。

    argo submit artifact-passing.yaml
  4. 執行以下命令,查看工作流程狀態。

    argo list