Difficulty: Beginner
Estimated Time: 10 to 20 minutes

In this scenario you will:

  1. Learn about reuse using workflow templates.
  2. Learn about running a workflow on schedule using cron workflows.

Let's recap:

  • A workflow template is a workflow that can be reused or as a library item.
  • A cron workflow is a workflow that runs on a schedule.

Please let us know what can be improved.

Reuse

Step 1 of 2

Workflow Templates

Workflow templates (not to be confused with a template) allow you to create a library of code that can be reused. They're similar to pipelines in Jenkins.

Workflow templates have a different kind to a workflow, but are otherwise very similar:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello
spec:
  entrypoint: main
  templates:
    - name: main
      container:
        image: docker/whalesay

Lets created this workflow template:

argo template create hello-workflowtemplate.yaml

You can also manage templates using kubectl:

kubectl apply -f hello-workflowtemplate.yaml

This allows you to use GitOps to manage your templates.

To submit a template, you can use the UI or the CLI:

argo submit --watch --from workflowtemplate/hello

You should see:

STEP            TEMPLATE  PODNAME      DURATION  MESSAGE
 ✔ hello-c622t  main      hello-c622t  33s

Lets take a look at the workflow you created:

argo get @latest -o yaml

Look for the workflow specification in the output:

spec:
  workflowTemplateRef:
    name: hello

Note how the specification of the workflow is actually a reference to the template.

Exercise

  • Use the user interface to submit a workflow template.
  • Update the workflow template to add some parameters (e.g. to print a message). Use argo submit --from to submit it with different parameters.