Argo

Installation

Install Argo CLI:

brew install argoproj/tap/argo

Install Argo Workflows in Kubernetes:

kubectl create namespace argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/stable/manifests/install.yaml

Access the Argo UI

Port-forward the Argo UI:

kubectl -n argo port-forward deployment/argo-server 2746:2746

Access UI: Open a browser and go to http://localhost:2746.

Submit a Workflow

Create a simple workflow YAML (hello-world.yaml):

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world"]

Submit the workflow:

argo submit hello-world.yaml

Monitor Workflows

List workflows:

argo list

Get workflow details:

argo get <workflow-name>

Watch workflow logs:

argo logs -w <workflow-name>

Watch the progress of a workflow:

argo watch <workflow-name>

Workflow Lifecycle Management

Suspend a running workflow:

argo suspend <workflow-name>

Resume a suspended workflow:

argo resume <workflow-name>

Terminate a running workflow:

argo terminate <workflow-name>

Retry a failed workflow:

argo retry <workflow-name>

Create Workflow Templates

Define a template (workflow-template.yaml):

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello-world-template
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world from template"]

Create the template:

kubectl apply -f workflow-template.yaml

Submit a workflow using the template:

argo submit --from workflowtemplate/hello-world-template

Using Parameters in Workflows

Define a parameterized workflow (params-workflow.yaml):

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-param-
spec:
  entrypoint: whalesay
  arguments:
    parameters:
    - name: message
      value: "hello world"
  templates:
  - name: whalesay
    inputs:
      parameters:
      - name: message
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]

Submit with parameters:

argo submit params-workflow.yaml -p message="hello Argo"

Artifacts and Outputs

Define a workflow with artifacts (artifacts-workflow.yaml):

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: artifacts-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world"]
    outputs:
      artifacts:
      - name: message
        path: /tmp/message

DAG and Steps

Define a DAG workflow (dag-workflow.yaml):

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: dag-diamond-
spec:
  entrypoint: diamond
  templates:
  - name: diamond
    dag:
      tasks:
      - name: A
        template: echo
        arguments:
          parameters: [{name: message, value: "A"}]
      - name: B
        dependencies: [A]
        template: echo
        arguments:
          parameters: [{name: message, value: "B"}]
      - name: C
        dependencies: [A]
        template: echo
        arguments:
          parameters: [{name: message, value: "C"}]
      - name: D
        dependencies: [B, C]
        template: echo
        arguments:
          parameters: [{name: message, value: "D"}]
  - name: echo
    inputs:
      parameters:
      - name: message
    container:
      image: alpine:3.7
      command: [sh, -c]
      args: ["echo {{inputs.parameters.message}}"]

Submit the DAG workflow:

argo submit dag-workflow.yaml

Clean Up

Delete a workflow:

argo delete <workflow-name>

Delete all workflows:

argo delete --all

Useful Commands

  • View Argo version:

    argo version
  • Get the status of a workflow:

    argo get <workflow-name>
  • Resume a suspended workflow:

    argo resume <workflow-name>

This cheat sheet should help you start with Argo Workflows in a Kubernetes environment. For more detailed information, refer to the Argo Workflows documentation.

Last updated

Was this helpful?