Migrate BatchCompute jobs to a distributed Argo workflow cluster

更新时间:
复制 MD 格式

Batch jobs are commonly used in the data processing, simulation, and scientific computing sectors. Batch jobs usually require large amounts of computing resources. Kubernetes clusters for distributed Argo workflows are developed based on the open source Argo Workflows project and comply with the standards of open source workflows. In workflow clusters, you can easily orchestrate workflows, run each step in containers, and complete compute-intensive jobs such as large-scale machine learning and simulation within a short period of time. You can also quickly run Continuous Integration and Continuous Delivery (CI/CD) pipeline jobs. Migrating scheduled jobs and batch jobs to workflow clusters helps you efficiently reduce O&M complexity and costs.

Why migrate to Argo Workflows

Batch computing has several constraints:

  • Job definitions require learning product-specific specifications, and some systems require purchasing designated devices or software.

  • Compute environments must be managed manually: specify vSwitch models and instance counts. The overall O&M cost is high because the system is not serverless.

  • Limited compute environments mean you must assign job priorities in queues, adding configuration complexity.

Argo Workflows addresses these constraints:

  • Cloud-native and based on open source Argo Workflows, with no dependency on proprietary products or software.

  • Supports complex task orchestration for data processing, simulation, and scientific computing.

  • Runs on nodeless elastic container instances provided by Alibaba Cloud.

  • Pay-as-you-go billing with no job queue — deploy compute resources at any scale based on demand, improving efficiency and reducing costs.

Key concepts

Batch computing

Batch computing has five core components that form a linear dependency chain: a compute environment hosts the infrastructure, a job queue routes work across compute environments, a job definition specifies how a job runs, and a job (or array job) is the actual unit of work submitted and executed.

image
Concept Description
Job A unit of work started after submitting Shell scripts, Linux executable files, or Docker container images to the batch computing system. The system allocates compute resources and starts the job.
Array job A collection of similar jobs submitted and run as a batch. All jobs in an array job share the same job definition. Use indexes to identify individual jobs. Each job instance may process a different dataset or task.
Job definition Specifies how a job runs. Must be created before running a job. Includes: the container image, commands and parameters, required CPU and memory, environment variables, and disk space.
Job queue Jobs submitted to the batch computing system enter a job queue and leave after scheduling. You can specify job priorities within a queue and associate a queue with a compute environment.
Compute environment Consists of compute resources for running jobs. You must specify the vSwitch model, maximum and minimum vCPU counts, and the unit price of preemptible instances for each compute environment.

Argo Workflows

Argo Workflows has three core building blocks. A template defines the smallest unit of work. A workflow orchestrates one or more templates. A workflow template makes reusable workflow definitions available across multiple workflows. All tasks ultimately run in pods on an ACK serverless cluster.

image
Concept Description
Template Defines a task (or job). Each workflow must contain at least one template. A template also specifies Kubernetes container configuration and input/output parameters.
Workflow Consists of one or more tasks (templates). You can serialize tasks, run them in parallel, or run only tasks that meet specified conditions. Tasks run in pods of a Kubernetes cluster.
Workflow template A reusable static workflow definition, similar to a function. You can reference and run a workflow template across different workflows, reusing definitions when building complex workflows.
ACK serverless cluster Provides the built-in compute environment for workflow clusters. After a workflow is submitted, tasks run on serverless elastic container instances — no Kubernetes node maintenance required. Supports large-scale workflows with tens of thousands of pods and hundreds of thousands of vCPUs. Compute resources are automatically released after workflows complete.

Feature mappings

The table below maps batch computing features to their Argo Workflows equivalents and highlights the key behavioral differences.

Category Batch computing Argo Workflows Key differences
User experience Batch computing CLI Argo Workflows CLI Argo CLI operates on Kubernetes-native YAML resources instead of JSON job definitions
JSON-defined jobs YAML-defined jobs Argo uses Kubernetes-standard YAML; no proprietary job schema to learn
SDK SDK Argo SDKs are open source and community-maintained
Key features Jobs Workflows A workflow is a Kubernetes resource, not a batch-system construct
Array jobs Argo Workflows - Loops Loops use withSequence or withItems; no separate array job type
Job dependencies Argo Workflows - DAG Dependencies are declared by task name, not by job ID — no scripting needed
Job environment variables Argo Workflows - Parameters Parameters support both static values and dynamic outputs from upstream tasks
Automated job retries Argo Workflows - Retrying Retry policies are defined inline in the template spec
Job timeouts Argo Workflows - Timeouts Timeouts apply at both the workflow and the individual step level
N/A Argo Workflows - Artifacts Native support for passing files between tasks; no external scripting needed
N/A Argo Workflows - Conditions Run tasks conditionally based on upstream task results
N/A Argo Workflows - Recursion Workflows can call themselves recursively — not possible in most batch systems
N/A Argo Workflows - Suspending/Resuming Pause and resume workflows mid-execution without losing state
GPU jobs Run workflows on a specified type of ECS instances Target specific ECS instance types, including GPU instances, via node selectors
Volumes Volumes Mount Object Storage Service (OSS), File Storage NAS (NAS), Cloud Parallel File System (CPFS), or disks
Job priority Argo Workflows - Priority Priority is set at submit time; serverless elasticity reduces contention
Job definitions Workflow templates Reusable across workflows; versioned as Kubernetes resources
Compute environment Job queues Serverless and elastic. No job queue is needed. Argo scales elastically on demand — no queue configuration or priority management
Compute environments ACK serverless clusters The cluster manages compute automatically; no vSwitch or instance count to configure
Ecosystem integration Eventing Eventing Trigger workflows from external events
Observability Observability Unified monitoring and logging for workflows

Workflow examples

Simple workflow

The following workflow creates a pod that uses the alpine image and runs the Shell command echo helloworld.

Modify this workflow to run custom Shell commands or execute commands in a custom image.

cat > helloworld.yaml << EOF
apiVersion: argoproj.io/v1alpha1
kind: Workflow                  # new type of k8s spec
metadata:
  generateName: hello-world-    # name of the workflow spec
spec:
  entrypoint: main         # invoke the main template
  templates:
    - name: main              # name of the template
      container:
        image: registry.cn-hangzhou.aliyuncs.com/acs/alpine:3.18-update
        command: [ "sh", "-c" ]
        args: [ "echo helloworld" ]
EOF
argo submit helloworld.yaml

Loops

Use loops to process large amounts of data in parallel — each iteration runs as an independent pod.

The following example packages a text file named pets.input and a script named print-pet.sh in a custom image. The loop creates five pods, passing job-index values 1 through 5 as input parameters. Each pod prints the pet listed on the corresponding row in pets.input. For more information about the source files, see the GitHub repository.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: loops-
spec:
  entrypoint: loop-example
  templates:
  - name: loop-example
    steps:
    - - name: print-pet
        template: print-pet
        arguments:
          parameters:
          - name: job-index
            value: "{{item}}"
        withSequence:  # loop to run print-pet template with parameter job-index 1 ~ 5 respectively.
          start: "1"
          end: "5"
  - name: print-pet
    inputs:
      parameters:
      - name: job-index
    container:
      image: acr-multiple-clusters-registry.cn-hangzhou.cr.aliyuncs.com/ack-multiple-clusters/print-pet
      command: [/tmp/print-pet.sh]
      args: ["{{inputs.parameters.job-index}}"] # input parameter job-index as args of container

For more information, see Argo Workflows - Loops.

DAGs (MapReduce)

In batch computing systems, you must specify job dependencies using job IDs — but a job ID is only available after the job is submitted. The typical workaround is a script like this:

// Job B depends on Job A. Job B starts only after Job A completes.
batch submit JobA | get job-id
batch submit JobB --dependency job-id (JobA)

As the number of jobs grows, these dependency scripts become hard to maintain.

Argo Workflows lets you declare dependencies by task name directly in the workflow definition:

image
  • Task B and Task C depend on Task A.

  • Task D depends on Task B and Task C.

# The following workflow executes a diamond workflow
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
        depends: "A"
        template: echo
        arguments:
          parameters: [{name: message, value: B}]
      - name: C
        depends: "A"
        template: echo
        arguments:
          parameters: [{name: message, value: C}]
      - name: D
        depends: "B && C"
        template: echo
        arguments:
          parameters: [{name: message, value: D}]
  - name: echo
    inputs:
      parameters:
      - name: message
    container:
      image: alpine:3.7
      command: [echo, "{{inputs.parameters.message}}"]

For a sample MapReduce workflow that creates shards and aggregates results, see map-reduce.

Migrate from batch computing to Argo Workflows

Step 1: Assess and plan

Before converting any jobs, audit your existing batch workloads across these dimensions:

  • Job inventory: List all jobs, including their dependencies, resource requests (CPU, memory, GPU), and runtime parameters.

  • Prioritization: Identify business-critical jobs and high-complexity jobs separately. Start your migration with a simple, non-critical job to build confidence before tackling complex workflows.

  • Feature gaps: Map each batch computing feature to its Argo Workflows equivalent using the feature mappings table above. Skip compute environment design and job priority configuration — Kubernetes clusters for distributed Argo workflows use serverless elastic container instances and require no queue management.

Step 2: Create a Kubernetes cluster for distributed Argo workflows

See Create a workflow cluster.

Step 3: Convert job definitions

Convert batch jobs to Argo workflows based on the feature mappings. Use the Argo Workflows SDK to automate workflow creation and system integration where needed.

Step 4: Prepare storage

Make sure the cluster can access the data that your workflows need. Mount OSS buckets, NAS file systems, CPFS file systems, or disks to the cluster. For instructions, see Use volumes.

Step 5: Verify workflows

Run both systems in parallel before decommissioning the batch system:

  1. Keep existing batch jobs inactive but available for comparison.

  2. Trigger the same workload on both systems for the same input data.

  3. Write outputs to separate paths to avoid conflicts.

  4. Compare results — data accuracy, output structure, and resource usage — to confirm parity.

  5. After confirming correctness, decommission the batch jobs.

Keep the parallel-run period short. Extended dual maintenance increases operational overhead and the risk of divergence.

Step 6: Enable monitoring and logging

Enable observability for the cluster to check workflow status and logs. Use preemptible instances to reduce compute costs further.

Usage notes

  • Argo workflows replace mainstream batch computing systems across user experience, core features, compute environments, and ecosystem integration. They are particularly well-suited for complex workflow orchestration and scenarios that benefit from elastic, nodeless compute.

  • Workflow definitions comply with Kubernetes YAML specifications, and task definitions comply with Kubernetes container specifications. If your team already uses Kubernetes, the learning curve is minimal.

  • The compute environment uses elastic container instances (nodeless). Resources scale on demand with pay-as-you-go billing, and no job queue is needed.

  • Using preemptible instances reduces compute costs further.

  • Distributed workflows are suitable for CI/CD, data processing, simulation, and scientific computing.

What's next