假设使用相同的模板有两个不同的 argo 工作流程whalesay
:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: workflow1
spec:
# invoke the whalesay template with
# "hello world" as the argument
# to the message parameter
entrypoint: whalesay
arguments:
parameters:
- name: message
value: hello world
templates:
- name: whalesay
inputs:
parameters:
- name: message
container:
# run cowsay with that message input parameter as args
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: workflow2
spec:
entrypoint: hello-hello-hello
templates:
- name: hello-hello-hello
# Instead of just running a container
# This template has a sequence of steps
steps:
- - name: hello1
template: whalesay
arguments:
parameters:
- name: message
value: "hello1"
- - name: hello2a
template: whalesay
arguments:
parameters:
- name: message
value: "hello2a"
- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
有没有办法避免在两个不同的工作流程中重复(和维护)相同的模板?也许类似于 WorklowTemplate,例如:
apiVersion: ...
kind: TemplateTemplate
name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: workflow1
metadata:
name:
spec:
entrypoint: whalesay
arguments:
parameters:
- name: message
value: hello world
templates:
- templateRef: whalesay
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: workflow2
spec:
entrypoint: hello-hello-hello
templates:
- name: hello-hello-hello
# Instead of just running a container
# This template has a sequence of steps
steps:
- - name: hello1
templateRef: whalesay
arguments:
parameters:
- name: message
value: "hello1"
- - name: hello2a
templateRef: whalesay
arguments:
parameters:
- name: message
value: "hello2a"