Kubernetes Argo将参数提交到步骤

时间:2019-06-11 15:52:16

标签: kubernetes yaml

我正在遵循Argo GitHub上的示例,但是当我将模板移到步骤中时,无法更改message的参数。

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}}"]

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

argo submit .\workflow.yml -p message="goodbye world"

它仍然打印出您好世界,而不是再见世界。不知道为什么

1 个答案:

答案 0 :(得分:1)

-p参数设置在工作流程规范的arguments字段中定义的全局工作流程参数。提供更多信息here。要使用全局参数,应更改以下工作流程:

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}}"]