
Reading the specification is useful, but most engineers learn Argo Workflows fastest by copying a working example and changing it. This guide collects twelve patterns that appear again and again in real pipelines. Every example is complete, self-contained YAML that you can submit to a cluster with argo submit -n argo file.yaml --watch, and each one is followed by an explanation of how it works and when to use it.
The examples use small public images such as busybox, alpine and python so they run quickly on any cluster. Replace them with your own images once you understand the pattern. You can also browse and download all of them from the interactive Workflow Examples Library.
How to Use These Examples
- Copy the YAML into a file or into the YAML validator to check it first.
- Submit it with the Argo CLI into a namespace where workflows are allowed to run.
- Watch the graph in the Argo UI or with
argo get @latest. - Change one field at a time and resubmit to see the effect.
All examples assume the service account used by workflows has the minimal executor permissions described in the Kubernetes integration guide.
Example 1: Parameterised Container
The simplest useful pattern is a container whose behaviour depends on a parameter supplied at submit time.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: param-
spec:
entrypoint: main
arguments:
parameters:
- name: environment
value: staging
templates:
- name: main
inputs:
parameters:
- name: environment
container:
image: alpine:3.20
command: [sh, -c]
args: ["echo Deploying to {{inputs.parameters.environment}}"]
When to use it: any job that runs the same logic against different targets, such as environments, regions or customers. Submit with -p environment=production to override the default.
Example 2: Inline Script Template
Script templates embed source code directly in the manifest. Standard output becomes outputs.result.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: script-
spec:
entrypoint: main
templates:
- name: main
script:
image: python:3.12-alpine
command: [python]
source: |
import datetime
print(datetime.date.today().isoformat())
When to use it: short glue logic, quick calculations or generating JSON for a later loop. For anything longer than a few dozen lines, build a proper image so the code can be tested and versioned separately.
Example 3: Sequential and Parallel Steps
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: steps-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: extract
template: log
arguments: {parameters: [{name: msg, value: extract}]}
- - name: transform-a
template: log
arguments: {parameters: [{name: msg, value: transform-a}]}
- name: transform-b
template: log
arguments: {parameters: [{name: msg, value: transform-b}]}
- - name: load
template: log
arguments: {parameters: [{name: msg, value: load}]}
- name: log
inputs: {parameters: [{name: msg}]}
container:
image: busybox:1.36
command: [echo, "{{inputs.parameters.msg}}"]
How it works: the double dash - - starts a new sequential stage. Steps listed under the same stage run in parallel. This is the classic extract-transform-load shape.
Example 4: DAG With Diamond Dependencies
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: diamond-
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: A
template: log
arguments: {parameters: [{name: msg, value: A}]}
- name: B
depends: A
template: log
arguments: {parameters: [{name: msg, value: B}]}
- name: C
depends: A
template: log
arguments: {parameters: [{name: msg, value: C}]}
- name: D
depends: B && C
template: log
arguments: {parameters: [{name: msg, value: D}]}
- name: log
inputs: {parameters: [{name: msg}]}
container:
image: busybox:1.36
command: [echo, "{{inputs.parameters.msg}}"]
When to use it: irregular dependency graphs. B and C start as soon as A succeeds; D waits for both. Paste it into the DAG visualizer to see the diamond.
Example 5: Passing Output Parameters
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: outputs-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: generate
template: generate
- - name: consume
template: consume
arguments:
parameters:
- name: build-id
value: "{{steps.generate.outputs.parameters.build-id}}"
- name: generate
container:
image: alpine:3.20
command: [sh, -c]
args: ["date +%s | tr -d '\\n' > /tmp/id"]
outputs:
parameters:
- name: build-id
valueFrom:
path: /tmp/id
- name: consume
inputs: {parameters: [{name: build-id}]}
container:
image: alpine:3.20
command: [echo, "Build {{inputs.parameters.build-id}}"]
Tip: strip trailing newlines when the value will be used in conditions or URLs. Declare valueFrom.default if the file might not exist, so downstream steps still resolve.
Example 6: Passing Artifacts Between Steps
Artifacts require a configured artifact repository.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: artifacts-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: produce
template: produce
- - name: consume
template: consume
arguments:
artifacts:
- name: report
from: "{{steps.produce.outputs.artifacts.report}}"
- name: produce
container:
image: alpine:3.20
command: [sh, -c]
args: ["echo 'rows: 1024' > /tmp/report.txt"]
outputs:
artifacts:
- name: report
path: /tmp/report.txt
- name: consume
inputs:
artifacts:
- name: report
path: /input/report.txt
container:
image: alpine:3.20
command: [cat, /input/report.txt]
When to use it: files, datasets, model weights, test reports — anything larger than a small string.
Example 7: Dynamic Fan-Out With withParam
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: fanout-
spec:
entrypoint: main
parallelism: 3
templates:
- name: main
steps:
- - name: list
template: list-shards
- - name: process
template: process
arguments:
parameters: [{name: shard, value: "{{item}}"}]
withParam: "{{steps.list.outputs.result}}"
- name: list-shards
script:
image: python:3.12-alpine
command: [python]
source: |
import json
print(json.dumps([f"shard-{i}" for i in range(6)]))
- name: process
inputs: {parameters: [{name: shard}]}
container:
image: busybox:1.36
command: [sh, -c, "echo processing {{inputs.parameters.shard}}; sleep 5"]
How it works: the script prints a JSON array, Argo creates one node per element, and parallelism: 3 caps concurrency so the cluster is not flooded.
Example 8: Conditional Branching
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: branch-
spec:
entrypoint: main
arguments:
parameters: [{name: env, value: dev}]
templates:
- name: main
steps:
- - name: deploy-prod
template: say
when: "'{{workflow.parameters.env}}' == 'prod'"
arguments: {parameters: [{name: msg, value: "production deploy"}]}
- name: deploy-dev
template: say
when: "'{{workflow.parameters.env}}' != 'prod'"
arguments: {parameters: [{name: msg, value: "development deploy"}]}
- name: say
inputs: {parameters: [{name: msg}]}
container:
image: busybox:1.36
command: [echo, "{{inputs.parameters.msg}}"]
Tip: quote string values on both sides of the comparison; unquoted words are treated as identifiers and fail evaluation.
Example 9: Retries With Exponential Backoff
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: retry-
spec:
entrypoint: flaky
templates:
- name: flaky
retryStrategy:
limit: "4"
retryPolicy: Always
backoff: {duration: "5s", factor: "2", maxDuration: "2m"}
script:
image: python:3.12-alpine
command: [python]
source: |
import random, sys
sys.exit(0 if random.random() > 0.6 else 1)
How it works: each failed attempt waits longer — 5, 10, 20 seconds — until it succeeds or the limit or maxDuration is reached. The UI shows every attempt as a child node.
Example 10: Exit Handler for Notifications
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: exit-handler-
spec:
entrypoint: main
onExit: report
templates:
- name: main
container:
image: busybox:1.36
command: [sh, -c, "exit 1"]
- name: report
steps:
- - name: on-success
template: msg
when: "{{workflow.status}} == Succeeded"
arguments: {parameters: [{name: text, value: "All good"}]}
- name: on-failure
template: msg
when: "{{workflow.status}} != Succeeded"
arguments: {parameters: [{name: text, value: "Pipeline failed: {{workflow.name}}"}]}
- name: msg
inputs: {parameters: [{name: text}]}
container:
image: busybox:1.36
command: [echo, "{{inputs.parameters.text}}"]
When to use it: alerts, cleanup and status reporting that must happen whatever the result.
Example 11: Creating a Kubernetes Resource
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: k8s-job-
spec:
entrypoint: create-job
serviceAccountName: argo-workflow
templates:
- name: create-job
resource:
action: create
successCondition: status.succeeded > 0
failureCondition: status.failed > 2
manifest: |
apiVersion: batch/v1
kind: Job
metadata:
generateName: pi-
spec:
backoffLimit: 2
template:
spec:
restartPolicy: Never
containers:
- name: pi
image: perl:5.40
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(200)"]
Note: the service account needs permission to create and watch Jobs. Resource templates are ideal for orchestrating other operators, such as Spark or training jobs.
Example 12: Manual Approval Gate
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: approval-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: build
template: say
arguments: {parameters: [{name: msg, value: "build complete"}]}
- - name: approve
template: wait-for-approval
- - name: release
template: say
arguments: {parameters: [{name: msg, value: "released"}]}
- name: wait-for-approval
suspend:
duration: "24h"
- name: say
inputs: {parameters: [{name: msg}]}
container:
image: busybox:1.36
command: [echo, "{{inputs.parameters.msg}}"]
How it works: the workflow pauses at approve. Resume it with argo resume <name> or the UI button. The duration acts as a timeout; when it expires the step completes and the workflow continues, so remove it if approval must be explicit.
Choosing the Right Pattern
With twelve patterns available it helps to know which one to reach for first. The table below maps common requirements to the example that solves them.
| Requirement | Pattern | Example |
|---|---|---|
| Same job, different target | Parameterised container | 1 |
| Small piece of logic without a custom image | Script template | 2 |
| Mostly linear stages with some parallelism | Steps | 3 |
| Irregular dependencies, maximum concurrency | DAG | 4 |
| Pass a small value forward | Output parameters | 5 |
| Pass files or datasets forward | Artifacts | 6 |
| Unknown number of work items | withParam fan-out |
7 |
| Different behaviour per environment | when conditions |
8 |
| Flaky dependencies | Retries with backoff | 9 |
| Always notify or clean up | Exit handler | 10 |
| Drive another Kubernetes controller | Resource template | 11 |
| Human sign-off | Suspend template | 12 |
Adapting Examples for Production
The examples are intentionally minimal so that each one demonstrates a single idea. Before you run any of them against real systems, add the operational guard rails that production workloads need. Most teams treat the following list as a definition of done for every new workflow:
- Resource requests and limits on every container, sized from observed usage rather than guesses.
- A dedicated service account with only the permissions that workflow needs, instead of the namespace default.
- Pinned image tags or digests so a rebuilt upstream image cannot silently change behaviour.
activeDeadlineSecondsat workflow level, and on long-running templates, to stop runaway executions.ttlStrategyandpodGCso completed workflows and pods do not accumulate in etcd.- Labels such as
team,appandcost-centeron the workflow metadata, which make filtering in the UI and cost reporting much easier. - Secrets mounted from Kubernetes Secrets, never passed as parameters, because parameters are visible in the UI and in the workflow status.
Our Configuration Checker scores a manifest against these rules and lists what is missing, which is a quick way to review an example after you have customised it.
Combining Patterns Into a Real Pipeline
Production pipelines rarely use one pattern in isolation. A typical nightly data job, for instance, starts with a script that lists the partitions that arrived during the day, fans out over them with withParam, processes each partition in a container with retries, writes results as artifacts, merges them in a final DAG task and reports the outcome through an exit handler. Each of those pieces is one of the examples above.
The trick to combining them cleanly is to keep orchestration and work separate. Put the DAG or steps logic in one template that only calls other templates, and keep each work template focused on a single container. That separation keeps the graph readable in the UI, makes individual steps easy to test in isolation, and lets you move shared work templates into a WorkflowTemplate later without rewriting the orchestration.
Troubleshooting the Examples
- Example 6 fails with "artifact repository not configured": add an artifact repository to the controller ConfigMap or run MinIO locally.
- Example 11 fails with "forbidden": grant the workflow service account
create,get,listandwatchonjobsin thebatchAPI group. - Example 7 runs one item containing the whole array: the script printed extra text. Only the JSON array may be written to stdout.
- Conditions always skip: print the value you are comparing; whitespace and quoting are the usual culprits.
Frequently Asked Questions
Where can I find more official examples?
The Argo Workflows repository contains an examples folder with well over a hundred manifests covering almost every feature.
Can I combine these patterns?
Yes. Real pipelines usually mix several — for example a DAG whose tasks use retries, artifacts and an exit handler.
Do these examples work on version 3.x?
Yes. They avoid fields that changed between the 3.x and 4.x lines, so they run on any recent release.
Should examples become WorkflowTemplates?
For anything you run repeatedly, yes. Templates let teams call shared steps with templateRef instead of copying YAML.
Key Takeaways
- Start from a working example and change one field at a time.
- Keep orchestration templates separate from work templates.
- Add resources, deadlines, cleanup and least-privilege service accounts before production.
- Use artifacts for files and parameters for small values.
- Validate every customised example with the validator and configuration checker before submitting it.
Conclusion
These twelve patterns cover the majority of what production pipelines need. Download them from the Examples Library, generate variations with the Snippet Generator, and read the YAML reference to understand every field they use. Each pattern is a starting point, not a finished pipeline.



