Skip to content

Argo Workflow templates: CAPA practice questions

The word template means two different things in Argo Workflows, and the documentation itself calls the collision unfortunate. A template, in lower case, is one entry in the templates list of a workflow and works like a function: it has inputs, outputs and a body.

By Ibrahim Yesilay · Published · Updated

Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.

What Argo Workflow templates covers in CAPA

The word template means two different things in Argo Workflows, and the documentation itself calls the collision unfortunate. A template, in lower case, is one entry in the templates list of a workflow and works like a function: it has inputs, outputs and a body. A WorkflowTemplate is a separate cluster resource that stores a reusable workflow definition, including one or more of those templates.

There are nine template types in two groups. Template definitions do work: container runs an image, script runs an inline script in an image and exposes its standard output as outputs.result, resource creates, applies, patches or deletes a Kubernetes object, suspend waits for a duration or for someone to resume the workflow, and container set, HTTP and plugin cover more specialised cases. Template invocators call other templates: steps runs them as a list of stages, and dag runs them as tasks with dependencies. A workflow names one template as its entrypoint, and that template usually is a steps or dag template that calls the rest.

A WorkflowTemplate is namespaced. Another workflow can call a single template from it with templateRef, giving the WorkflowTemplate name and the template name, from inside a steps or dag template. A workflow can also be created from the whole definition with workflowTemplateRef; any arguments the new workflow passes are merged with the arguments defined in the WorkflowTemplate. A ClusterWorkflowTemplate is the cluster-scoped equivalent, so teams in every namespace can share it, and a reference to it adds clusterScope: true.

A CronWorkflow wraps a workflow spec in a schedule. Its schedules field must be a non-empty list of cron expressions, which replaced the older single schedule field, and an optional timezone sets the clock it reads. concurrencyPolicy decides what happens when a run is due while an earlier one is still going: Allow, the default, starts it anyway, Forbid skips it and Replace removes the old run first. startingDeadlineSeconds lets a run that was missed during a controller outage still start, and history limits keep three successful and one failed workflow by default. A CronWorkflow can be paused with suspend instead of being deleted.

Key points

  • A template is a step definition inside a workflow; a WorkflowTemplate is a stored, reusable workflow.
  • templateRef calls one template from a WorkflowTemplate; workflowTemplateRef starts a workflow from all of it.
  • ClusterWorkflowTemplates are shared across namespaces and referenced with clusterScope: true.
  • CronWorkflow concurrencyPolicy defaults to Allow; Forbid skips overlapping runs and Replace removes the old one.

Three sample questions

12 CAPA questions on Argo Workflow templates, 12 with explanations. How practice works

Question 1

Which Argo Workflows feature allows you to share common workflow steps across multiple workflows?
  1. A.Templates defined inside a single Workflow, visible only within that Workflow's own spec
  2. B.WorkflowTemplates
  3. C.SharedSteps, a field under spec that lists steps for other workflows to import
  4. D.CommonWorkflows

Correct answer: B

A WorkflowTemplate is a Workflow definition stored in the cluster, intended as a library of frequently used templates that other workflows reference through templateRef. That reuse across workflows is what the question asks for. Why the other options are wrong. "Templates defined inside a single Workflow, visible onl...": templates listed in one Workflow's own spec.templates are local to it; sharing them needs a WorkflowTemplate referenced via templateRef. "SharedSteps, a field under spec that lists steps for ot...": no SharedSteps field or resource appears in the Workflow field reference. "CommonWorkflows": no CommonWorkflows resource appears in the Workflow concepts or templates docs; the reusable resource is WorkflowTemplate.

Sources: Argo Workflows docs: Workflow Templates, Argo Workflows docs: Fields

Question 2

Which feature allows you to suspend a workflow at a specific step?
  1. A.Using suspend: true in the step
  2. B.Using a suspend template
  3. C.Using wait: true
  4. D.Using pause: true

Correct answer: B

A suspend template (suspend: {}, optionally with a duration) used as a step halts the workflow at that point until it is resumed, for example with argo resume. The suspending page builds an approve step exactly this way. Why the other options are wrong. "Using suspend: true in the step": suspend: true on the workflow spec is a boolean that suspends the whole workflow, not a marker on a particular step. "Using wait: true": wait is not a documented step or template field. "Using pause: true": pause is not a documented step or template field either.

Sources: Argo Workflows docs: Suspending, Argo Workflows docs: Fields

Question 3

What is a WorkflowTemplate?
  1. A.A template for generating workflows from events received by an EventSource and a Sensor
  2. B.A container template within a workflow
  3. C.A reusable workflow definition that can be referenced by multiple workflows
  4. D.A Helm template for deploying Argo Workflows

Correct answer: C

A WorkflowTemplate is a namespaced definition of a workflow that other workflows reuse, either by calling one of its templates with templateRef or by starting from the whole definition with workflowTemplateRef. The cluster-scoped variant is the separate ClusterWorkflowTemplate. Why the other options are wrong. "A template for generating workflows from events receive...": event-driven submission is done by Argo Events or WorkflowEventBindings. "A container template within a workflow": that is a template inside spec.templates, not a WorkflowTemplate resource. "A Helm template for deploying Argo Workflows": it is an Argo Workflows CRD, unrelated to Helm.

Sources: Argo Workflows docs: Workflow Templates, Argo Workflows docs: Cluster Workflow Templates

Practice this topic

Focus mode keeps every question on Argo Workflow templates until you leave it. 10 free guest answers, then a free account; no credit card.

Or open CAPA practice across all topics.

Sources

The explanation above was checked against these official documents.