Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Workflow of workflows pattern #3536

Merged
merged 14 commits into from
Jul 23, 2020
30 changes: 30 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ Workflow is the definition of a workflow resource

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -559,6 +561,8 @@ WorkflowSpec is the specification of a Workflow.

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -885,6 +889,8 @@ CronWorkflowSpec is the specification of a CronWorkflow

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -1174,6 +1180,8 @@ WorkflowTemplateSpec is a spec of WorkflowTemplate.

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -1357,6 +1365,8 @@ Arguments to a template

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -1694,6 +1704,8 @@ Template is a reusable and composable unit of execution in a workflow

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -1777,6 +1789,8 @@ WorkflowTemplateRef is a reference to a WorkflowTemplate resource.

- [`cron-backfill.yaml`](https://github.com/argoproj/argo/blob/master/examples/cron-backfill.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`workflow-template-ref-with-entrypoint-arg-passing.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/workflow-template-ref-with-entrypoint-arg-passing.yaml)

- [`workflow-template-ref.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/workflow-template-ref.yaml)
Expand Down Expand Up @@ -2107,6 +2121,8 @@ Parameter indicate a passed string parameter to a service template with an optio

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -2409,6 +2425,8 @@ Inputs are the mechanism for passing parameters, artifacts, volumes from one tem

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`templates.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/templates.yaml)
</details>

Expand Down Expand Up @@ -2668,6 +2686,8 @@ Pod metdata

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -2714,6 +2734,8 @@ ResourceTemplate is a template subtype to manipulate kubernetes resources
- [`resource-delete-with-flags.yaml`](https://github.com/argoproj/argo/blob/master/examples/resource-delete-with-flags.yaml)

- [`resource-flags.yaml`](https://github.com/argoproj/argo/blob/master/examples/resource-flags.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)
</details>

### Fields
Expand Down Expand Up @@ -2959,6 +2981,8 @@ WorkflowStep is a reference to a template to execute in a series of step

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)

- [`retry-with-steps.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/retry-with-steps.yaml)
Expand Down Expand Up @@ -3842,6 +3866,8 @@ ObjectMeta is metadata that all persisted resources must have, which includes al

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -4970,6 +4996,8 @@ PersistentVolumeClaimSpec describes the common attributes of storage devices and

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down Expand Up @@ -5954,6 +5982,8 @@ ListMeta describes metadata that synthetic resources must have, including lists

- [`work-avoidance.yaml`](https://github.com/argoproj/argo/blob/master/examples/work-avoidance.yaml)

- [`workflow-of-workflows.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-of-workflows.yaml)

- [`dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/dag.yaml)

- [`hello-world.yaml`](https://github.com/argoproj/argo/blob/master/examples/workflow-template/hello-world.yaml)
Expand Down
100 changes: 100 additions & 0 deletions docs/workflow-of-workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Workflow of Workflows

> v2.9 and after

## Introduction
A workflow can trigger one or more workflow and manager their result.
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved

## Examples
You can use `workflowTemplateRef` to trigger a workflow inline.
1. Define your workflow as a `workflowtemplate`.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: workflow-template-submittable
spec:
entrypoint: whalesay-template
arguments:
parameters:
- name: message
value: hello world
templates:
- name: whalesay-template
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
```
2. Create the `Workflowtemplate` in cluster using `argo template create <yaml>`
3. Define the workflow of workflows.
```yaml
# This template demonstrates a workflow of workflows.
# Workflow triggers one or more workflow and manage it.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-of-workflows-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: workflow1
template: triggerWorkflowUsingResourceWithoutArgument
arguments:
parameters:
- name: workflowtemplate
value: "workflow-template-submittable"
- - name: workflow2
template: triggerWorkflowUsingResourceWithArgument
arguments:
parameters:
- name: workflowtemplate
value: "workflow-template-submittable"
- name: message
value: "Welcome Argo"

- name: triggerWorkflowUsingResourceWithoutArgument
inputs:
parameters:
- name: workflowtemplate
resource:
action: create
manifest: |
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-of-workflows-1-
spec:
workflowTemplateRef:
name: {{inputs.parameters.workflowtemplate}}
successCondition: status.phase == Succeeded
failureCondition: status.phase in (Failed, Error)

- name: triggerWorkflowUsingResourceWithArgument
inputs:
parameters:
- name: workflowtemplate
- name: message
resource:
action: create
manifest: |
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-of-workflows-2-
spec:
arguments:
parameters:
- name: message
value: {{inputs.parameters.message}}
workflowTemplateRef:
name: {{inputs.parameters.workflowtemplate}}
successCondition: status.phase == Succeeded
failureCondition: status.phase in (Failed, Error)
```
63 changes: 63 additions & 0 deletions examples/workflow-of-workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This template demonstrates a workflow of workflows.
# Workflow triggers one or more workflow and manage it.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-of-workflows-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: workflow1
template: triggerWorkflowUsingResourceWithoutArgument
arguments:
parameters:
- name: workflowtemplate
value: "workflow-template-submittable"
- - name: workflow2
template: triggerWorkflowUsingResourceWithArgument
arguments:
parameters:
- name: workflowtemplate
value: "workflow-template-submittable"
- name: message
value: "Welcome Argo"

- name: triggerWorkflowUsingResourceWithoutArgument
inputs:
parameters:
- name: workflowtemplate
resource:
action: create
manifest: |
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-of-workflows-1-
spec:
workflowTemplateRef:
name: {{inputs.parameters.workflowtemplate}}
successCondition: status.phase == Succeeded
failureCondition: status.phase in (Failed, Error)
- name: triggerWorkflowUsingResourceWithArgument
inputs:
parameters:
- name: workflowtemplate
- name: message
resource:
action: create
manifest: |
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-of-workflows-2-
spec:
arguments:
parameters:
- name: message
value: {{inputs.parameters.message}}
workflowTemplateRef:
name: {{inputs.parameters.workflowtemplate}}
successCondition: status.phase == Succeeded
failureCondition: status.phase in (Failed, Error)