All Products
Search
Document Center

Container Service for Kubernetes:Create a workflow

Last Updated:Mar 26, 2024

Workflows developed by Alibaba Cloud are based on Argo Workflows and are used to implement container orchestration in Kubernetes. Each step in a workflow is a container. This topic describes how to create a workflow in the Container Service for Kubernetes (ACK) console or by using a CLI.

Alibaba Cloud Genomics Service (AGS) workflows will soon be deprecated. We recommend that you use Kubernetes clusters for distributed Argo workflows (workflow clusters). Kubernetes clusters for distributed Argo workflows (workflow clusters) are designed for business scenarios including batch processing, data processing, scientific computing, and continuous integration. Workflow clusters can host open source Argo workflows for large-scale orchestration with high efficiency and elasticity. In addition, workflow clusters help you reduce operation costs.

Prerequisites

Note

If the workflow feature is disabled for your cluster, submit a ticket.

Background Information

Workflows developed by Alibaba Cloud are based on Argo Workflows and are used to implement container orchestration in Kubernetes. Each step in a workflow is a container.

Workflows are implemented by using Kubernetes CustomResourceDefinitions (CRDs). Therefore, you can use kubectl to manage workflows and integrate them with other Kubernetes services, such as volumes, Secrets, and role-based access control (RBAC). The workflow controller provides a complete set of workflow features, such as parameter substitution, storage, loops, and recursions.

You can create workflows in the ACK console or by using a CLI.

Create a workflow in the ACK console

  1. Log on to the ACK console.

  2. In the left-side navigation pane of the ACK console, click Clusters.

  3. On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.

  4. In the left-side navigation pane of the details page, choose Applications > Workflows.

  5. On the Workflows page, click Create in the upper-right corner of the page.

  6. In the Create from Template dialog box, configure the workflow and click Create.

    • Cluster: Select the cluster where you want to deploy the workflow. The workflow will be deployed in the selected cluster.

    • Namespace: Select the namespace to which the workflow belongs. By default, the default namespace is selected.

    • Sample Template: ACK provides YAML templates for various resource types to simplify the deployment of workflows. You can also create a custom template based on the YAML syntax to customize resource definitions.

    The following code block provides an example on how to create a Hello World workflow:

    apiVersion: Argoproj.io/v1alpha1
    Workflow                  # The type of Kubernetes object. 
    metadata:
      generateName: hello-world-    # The name of the workflow. 
    spec:
      entrypoint: whalesay          # Invoke the template of a whalesay image. 
      templates:
      - name: whalesay              # The name of the template.
        container:
          image: docker/whalesay
          command: [cowsay]
          args: ["hello world"]
          resources:                #Resource limits. 
            limits: 
              memory: 32Mi
              cpu: 100m
  7. After the workflow is created, you can view the created workflow on the Workflows page.

    εˆ›ε»ΊζˆεŠŸ

    You can click Details in the Actions column to view information about the workflow and pods.

Create a parameters workflow by using a CLI

  1. Create an arguments-parameters.yaml file based on the following code block:

    apiVersion: Argoproj.io/v1alpha1
    kind: Workflow
    metadata:
      generateName: hello-world-parameters-
    spec:
      # Specify "hello world" as the value of the parameter to invoke the template of a whalesay image. 
      entrypoint: whalesay
      arguments:
        parameters:
        - name: message
          value: hello world
    
      templates:
      - name: whalesay
        inputs:
          parameters:
          - name: message       # The description of the parameter. 
        container:
          # Use the input parameter args to run cowsay. 
          image: docker/whalesay 
          command: [cowsay]
          args: ["{{inputs.parameters.message}}"]
  2. Run the following command to deploy the parameters workflow:

    ags submit arguments-parameters.yaml -p message="goodbye world"

You can also use workflow templates provided in Sample workflow templates to create other types of workflow.

The AGS CLI is a command-line tool developed by Alibaba Cloud. It is compatible with open source Argo. The AGS CLI provides a simple way to submit, check, modify, and delete workflows. For more information, see Introduction to AGS CLI.