How to Set Up Argo Workflows on Kubernetes

Introduction

Argo Workflows is an open-source project that provides a declarative way to define and run complex workflows on Kubernetes. Argo Workflows allows you to orchestrate tasks that can run in parallel, in sequence, or in a DAG (directed acyclic graph) structure, and can integrate with various tools and services, such as Docker, Git, S3, Slack, etc. In this blog post, I will show you how to set up Argo Workflows on Kubernetes, and how to create and run a simple workflow.

Prerequisites

To follow this blog post, you need to have the following prerequisites:

  • A Kubernetes cluster with kubectl installed and configured.
  • Helm, a package manager for Kubernetes, installed and configured.
  • A Docker Hub account and the docker command-line tool installed and configured.

Step 1: Install Argo Workflows

To install Argo Workflows on your Kubernetes cluster, you can use Helm, which simplifies the installation and configuration process. To install Argo Workflows using Helm, follow these steps:

  • Add the Argo Helm repository to your Helm client:
helm repo add argo https://argoproj.github.io/argo-helm
  • Update your Helm repository cache:
helm repo update
  • Install the Argo Workflows chart with the name “argo” in the namespace “argo”:
helm install argo argo/argo --namespace argo --create-namespace

This will install Argo Workflows with the default settings, which include the Argo server, the Argo controller, and the Argo UI. You can customize the installation by using the values.yaml file or the –set flag. For more details, see the chart documentation.

  • Verify that Argo Workflows is installed and running:
kubectl get pods -n argo

You should see something like this:

NAME                                  READY   STATUS    RESTARTS   AGE
argo-server-7c8f4d9c6f-5xq9w          1/1     Running   0          2m
workflow-controller-fb8f8f6c6-9gk2r   1/1     Running   0          2m

Step 2: Access the Argo UI

To access the Argo UI, which provides a graphical interface to view and manage your workflows, you can use port forwarding to expose the Argo server service to your local machine. To do this, follow these steps:

  • Run the following command in a terminal:
kubectl port-forward svc/argo-server -n argo 2746:2746

This will forward the port 2746 of the Argo server service to the port 2746 of your local machine.

  • Open your browser and go to the URL:
http://localhost:2746

You should see the Argo UI, which should look something like this:

!Argo UI

Step 3: Create a Workflow

A workflow is a YAML file that defines the steps and dependencies of your tasks, as well as the inputs and outputs of each task. A workflow can also specify the container image, the command, the arguments, the environment variables, the resources, and the retries of each task. A workflow can be submitted to the Argo controller, which will create and run the corresponding Kubernetes pods and services.

To create a workflow, you can use any text editor or IDE of your choice, or you can use the Argo UI, which provides a code editor and a workflow builder. For this blog post, I will use the Argo UI to create a simple workflow that consists of two tasks: hello and goodbye. The hello task will print “Hello, world!” to the standard output, and the goodbye task will print “Goodbye, world!” to the standard output. The goodbye task will depend on the hello task, which means it will run after the hello task is completed.

To create a workflow using the Argo UI, follow these steps:

  • Click on the “New Workflow” button on the top right corner of the Argo UI.
  • In the code editor, paste the following YAML code:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-goodbye-
spec:
  entrypoint: hello-goodbye
  templates:
  - name: hello-goodbye
    steps:
    - - name: hello
        template: hello
    - - name: goodbye
        template: goodbye
        dependencies: [hello]
  - name: hello
    container:
      image: docker/whalesay:latest
      command: [cowsay]
      args: ["Hello, world!"]
  - name: goodbye
    container:
      image: docker/whalesay:latest
      command: [cowsay]
      args: ["Goodbye, world!"]

This is a simple workflow that defines the hello and goodbye tasks as container templates, and the hello-goodbye template as a steps template, which specifies the order and dependency of the tasks.

  • Click on the “Submit” button on the top right corner of the code editor.
  • In the pop-up window, click on the “Submit” button again.

This will submit the workflow to the Argo controller, which will create and run the corresponding Kubernetes pods and services.

Step 4: Run and Monitor the Workflow

To run and monitor the workflow, you can use the Argo UI, which provides a graphical representation of the workflow status, logs, and artifacts. To do this, follow these steps:

  • Click on the “Workflows” tab on the left sidebar of the Argo UI.
  • You should see your workflow listed with a generated name, such as “hello-goodbye-xxxxx”.
  • Click on your workflow name to see the details of your workflow.
  • You should see a DAG view of your workflow, which shows the tasks and their dependencies, as well as their status, such as running, succeeded, or failed.
  • You can also click on each task to see the logs and artifacts of that task, such as the standard output and the exit code.

You should see something like this:

!Workflow DAG

Conclusion

In this blog post, I showed you how to set up Argo Workflows on Kubernetes, and how to create and run a simple workflow. I hope you found this post useful and informative. Happy coding! 😊.

1 thought on “How to Set Up Argo Workflows on Kubernetes”

Leave a Comment

Your email address will not be published. Required fields are marked *