argo-workflow hypen name

# argoworkflow 3.1 이후 Expression Templates ({{= ... }}) 에서 step 이나 parameter 이름에 -  이 있는 경우 steps.aaa-bbb-ccc 는 사용하면 안되고 steps["aaa-bbb-ccc"] 로 사용해야 한다.

# 다음과 같이 step 동작을 테스트
# argo_workflow_steps_test.yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: ysoftman-wf
  namespace: ysoftman-workflow
spec:
  serviceAccountName: ysoftman-workflow
  entrypoint: ysoftman-wf
  templates:
    - name: aaa
      script:
        image: alpine
        command: [sh]
        source: |
          echo "---"
      outputs:
        parameters:
          - name: err-msg
            value: "ERROR!!!"

    - name: bbb
      inputs:
        parameters:
          - name: param1
      script:
        image: alpine
        command: [sh]
        source: |
          echo '{"code":400,"msg":"에러({{ inputs.parameters.param1  }})","desc":"test"}' > /tmp/response.json
      outputs:
        parameters:
          - name: response
            valueFrom:
              path: /tmp/response.json

    - name: ccc
      inputs:
        parameters:
          - name: param1
      script:
        image: alpine
        command: [sh]
        source: |
          echo '---> {{ inputs.parameters.param1 }}' > /tmp/response.json
      outputs:
        parameters:
          - name: response
            valueFrom:
              path: /tmp/response.json

    - name: ysoftman-wf
      steps:
        - - name: aaa-job
            template: aaa
        - - name: bbb-job
            template: bbb
            arguments:
              parameters:
                - name: param1
                  # value: "{{steps.aaa-job.outputs.parameters.err-msg}}"
                  # {{=...}} expression 식으로 사용하는 경우(https://argo-workflows.readthedocs.io/en/latest/variables/#expression)
                  value: "{{=steps['aaa-job'].outputs.parameters['err-msg']}}"
        - - name: ccc-job
            template: ccc
            arguments:
              parameters:
                - name: param1
                  # value: '{"message":"ysoftman-wf {{steps.bbb-job.outputs.parameters.response}}"}'
                  # {{=...}} expression 식으로 사용하는 경우(https://argo-workflows.readthedocs.io/en/latest/variables/#expression)
                  # single quote 이스케이프 처리시 '' 로 두번쓰면 된다.
                  # value: '{"message":"ysoftman-wf {{=steps[''bbb-job''].outputs.parameters[''response'']}}"}'
                  value: '{"message":"ysoftman-wf {{=replace(jsonpath(steps[''bbb-job''].outputs.parameters[''response''], "$.msg"), "!","~")}}"}'

# 접속 환경 설정
export ARGO_SERVER='argo-workflow.ysoftman.test:80'
export ARGO_HTTP1=true
export ARGO_SECURE=false
export ARGO_BASE_HREF=""
export ARGO_TOKEN="Bearer $(kubectl get secret argo-workflows -n argo-workflows -o=jsonpath='{.data.token}' | base64 --decode)"
export ARGO_NAMESPACE="argo-workflows"

# wf 실행
argo submit ./argo_workflow_steps_test.yaml

# wf 삭제
argo delete ysoftman-wf

# 테스트 결과
# bbb-job input/output

# ccc-job input/output

comments:

댓글 쓰기