聚合国内IT技术精华文章,分享IT技术精华,帮助IT从业人士成长

Some tips about Argo Workflows (on Kubernetes)

2020-03-02 11:53 浏览: 1219 次 我要评论(0 条) 字号:

Using Argo to execute workflows last week, I met some problems and also find the solutions.
1. Can’t parse “outputs”
By submitting this YAML file:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: robin-test-
spec:
  entrypoint: firststep
  templates:
  - name: firststep
    steps:
    - - name: generate
        template: generate-run
    - - name: execution
        template: execution-run
        arguments:
          parameters:
          - name: pair
            value: "{{item}}"
        withParam: "{{steps.generate.outputs.result}}"
  - name: generate-run
    container:
      image: gcr.io/robin/feature:latest
      command: ["bash", "-c"]
      args: ["cat my.json"]
  - name: execution-run
    inputs:
      parameters:
      - name: pair
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.pair}}"]

I met the error:

Failed to submit workflow: templates.firststep.steps[1].execution failed to resolve {{steps.generate.outputs.result}}]

Why the Argo could’t recognize the “steps.generate.outputs.result”? Because only “source” could have a default “output”, not “args”. So the template “generate-run” should be

...
  - name: generate-run
    container:
      image: gcr.io/robin/feature:latest
      command: ["bash", "-c"]
      source: |
        cat my.json

2. Can’t parse parameters from JSON
If the Argo report:

withParam value could not be parsed as a JSON list: xxx

it means the “output” of the previous step isn’t in standard JSON format. So make sure you have pretty JSON format output. For python, it should be like:

...
  - name: generate-run
    container:
      image: gcr.io/robin/feature:latest
      command: ["bash", "-c"]
      source: |
        python -c "import json; json.dump([{'id': key, 'name': value} for key, value in dictionary], sys.stdout)"



网友评论已有0条评论, 我也要评论

发表评论

*

* (保密)

Ctrl+Enter 快捷回复