Kubernetes Argo 将参数提交到步骤中

Sof*_*tey 1 yaml kubernetes argo-workflows

我正在关注 Argo GitHub 上的示例,但是当我将模板移动到步骤中时,我无法更改消息的参数。

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-parameters-
spec:
 # invoke the whalesay template with
 # "hello world" as the argument
 # to the message parameter
 entrypoint: entry-point

  templates:
  - name: entry-point
  steps:
    - - name: print-message
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: hello world



 - name: whalesay
   inputs:
     parameters:
     - name: message       # parameter declaration
    container:
    # run cowsay with that message input parameter as args
    image: docker/whalesay
    command: [cowsay]
    args: ["{{inputs.parameters.message}}"]
Run Code Online (Sandbox Code Playgroud)

如果我使用以下命令提交工作流程:

argo submit .\workflow.yml -p message="goodbye world"
Run Code Online (Sandbox Code Playgroud)

它仍然打印出 hello world 而不是 goodbye world。不知道为什么

小智 6

The -p argument sets the global workflow parameters defined in the arguments field of workflow spec. More information is available here . To use global parameters your workflow should be changed are the following:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-parameters-
spec:
  # invoke the whalesay template with
  # "hello world" as the argument
  # to the message parameter
  entrypoint: entry-point
  arguments:
    parameters:
    - name: message
      value: hello world

  templates:
  - name: entry-point
    steps:
    - - name: print-message
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: "{{workflow.parameters.message}}"
  - name: whalesay
    inputs:
      parameters:
       - name: message       # parameter declaration
    container:
      # run cowsay with that message input parameter as args
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]

Run Code Online (Sandbox Code Playgroud)