argo workflow retryStrategy 覆盖

argo workflow retryStrategy override

有什么方法可以覆盖 argo 中“WorkflowTemplate-retryStrategy”的值吗?

目前我们在 Argo WorkflowTemplate 中使用硬编码的 retryStrategy,如下所示(示例代码):

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: workflowtemplate-1
spec:
  entrypoint: task-template-1
  arguments:
    parameters:
    - name: "test"
      value: "testing"
  templates:
  - name: task-template-1
    retryStrategy:
      limit: 1
      retryPolicy: "Always"
    inputs:
        parameters:
          - name: "test"

有什么方法可以将其作为工作流参数(或类似的东西)的一部分进行覆盖? 就像下面代码中注释的“#”值:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: sample-workflow
spec:
  workflowTemplateRef:
    name: workflowtemplate-1
  # retryStrategy:
  #   limit: 3
  #   retryPolicy: "Always"
  arguments:
    parameters:
  #  - name: "retry"
  #    value: "2"

是的!只需为重试限制设置一个工作流参数。

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: workflowtemplate-1
spec:
  entrypoint: task-template-1
  arguments:
    parameters:
      - name: "retry"
        value: "1"
  templates:
    - name: task-template-1
      retryStrategy:
        limit: "{{workflow.parameters.retry}}"
        retryPolicy: "Always"
      container:
        image: docker/whalesay:latest
        command: ["false"]

---

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: sample-workflow
spec:
  workflowTemplateRef:
    name: workflowtemplate-1
  arguments:
    parameters:
    - name: "retry"
      value: "2"

如果您提交示例工作流,您会看到它会重试两次,而不是默认重试一次。

注意: 模板 limit 字段是 introduced in 2.11.0-rc1

如果您坚持使用早期版本,可以使用 workaround