Search code examples
kubernetesyamlargo-workflows

Kubernetes Argo submit parameter into steps


I'm following the examples on the Argo GitHub but I am unable to change the parameter of message when I move the template into steps.

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

If I submit the workflow using the following command:

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

It still prints out hello world and not goodbye world. Not sure why


Solution

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