All Products
Search
Document Center

Container Compute Service:Create a Job

Last Updated:Dec 25, 2024

A Job processes multiple short-lived, one-off tasks at a time to ensure that one or more pods in the tasks terminate with success. You can use a Job to create an application in the Alibaba Cloud Container Compute Service (ACS) console. This topic describes how to create a Job.

Background information

Jobs are classified into the following types based on the .spec.completions and .spec.parallelism parameters. The .spec.completions parameter specifies the number of pods that terminate with success before the Job is considered completed. Default value: 1. The .spec.parallelism parameter specifies the number of pods that the Job must run in parallel. Default value: 1.

Job type

completions

parallelism

Sample scenario

Action

One-off Job

1

1

Database migration

The Job starts only one pod. The Job is completed when the pod terminates with success.

Job with a fixed completion count

2+

1

Start pods one after one to process a work queue

The Job starts pods one by one. The Job is completed when the number of pods that terminate with success reaches the value of .spec.completions.

Parallel Job with a work queue

1

2+

A Job of this type starts multiple pods at a time.

The Job runs multiple pods in parallel and is considered completed when all pods terminate and at least one pod terminates with success.

Parallel Job with a fixed completion count

2+

2+

A Job of this type starts multiple pods at a time.

The Job runs multiple pods in parallel and is considered completed when the number of pods that terminate with success reaches the value of .spec.completions.

Procedure

Step 1: Configure basic application settings

  1. Log on to the ACS console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its ID or click Details in the Actions column of the cluster.

  3. In the left-side navigation pane of the details page, choose Workloads > Jobs.

  4. On the Jobs page, click Create from Image.

  5. On the Basic Information wizard page, configure the basic settings of the application.

    Parameter

    Description

    Name

    Enter a name for the application.

    Type

    Set Type to Job.

    Label

    Add labels to the application. The labels are used to identify the application.

    Annotations

    Add annotations to the application.

    Instance Type

    Select an instance type.

    QoS Type

    Select a QoS class. For more information, see Computing power QoS.

    • General-purpose pods support the Default and BestEffort QoS classes.

    • Performance-enhanced pods support only the Default QoS class.

  6. After you complete the basic settings, click Next.

Step 2: Configure container settings

  1. On the Container wizard page, configure the settings of containers.

    Note

    To add containers, click Add Container to the right of Container1.

    1. Set basic parameters.

      Parameter

      Description

      Image Name

      • Select images

        You can click Select images to select an image.

        • Container Registry Enterprise Edition: Select an image stored on a Container Registry Enterprise Edition instance. You must select the region and the Container Registry instance to which the image belongs. For more information about Container Registry, see What is Container Registry?

        • Container Registry Personal Edition: Select an image stored on a Container Registry Personal Edition instance. Make sure that Container Registry Personal Edition is activated. You must select the region and the Container Registry instance to which the image belongs.

        • Artifact Center: The artifact center contains base operating system images, base language images, and AI- and big data-related images for application containerization. In this example, an NGINX image is selected. For more information, see Overview of the artifact center.

      • Image pulling Secret

        ACS supports only the Always option. This means that the image is pulled from Container Registry each time you deploy an application or scale out the cluster. The image is not pulled from the local environment.

      • Set Image Pull Secret

        You can click Set Image Pull Secret to select a Secret to secure image pulling from a private registry.

      Required Resources

      Specify the resource requests of the container.

      • CPU: You can configure the CPU request and CPU limit of the container. By default, the CPU request equals the CPU limit. CPU resources are billed on a pay-as-you-go basis. If you use a YAML template to set a resource limit that differs from the resource request, the resource request is automatically overridden by the value of the resource limit. For more information, see Resource specifications.

      • Memory: You can configure the memory request and memory limit of the container. By default, the memory request equals the memory limit. Memory resources are billed on a pay-as-you-go basis. If you use a YAML template to set a resource limit that differs from the resource request, the resource request is automatically overridden by the value of the resource limit. For more information, see Resource specifications.

      Container Start Parameter

      Specify the startup options of the container. This parameter is optional.

      • stdin: sends the input from the ACS console to the container.

      • tty: sends start parameters that are defined in a virtual terminal to the console.

      Note

      stdin and tty are used together. In this case, the virtual terminal (tty) is associated with the stdin of the container. For example, an interactive program receives the stdin from the user and displays the content in the terminal.

      Init Containers

      If you select this check box, an init container is created. This parameter is optional.

      Init containers can be used to block or postpone the startup of application containers. Application containers in a pod start concurrently only after init containers start. For example, you can use init containers to verify the availability of a dependent service. You can run tools or scripts that are not provided by an application image in init containers to initialize the runtime environment for application containers. For example, you can run tools or scripts to set kernel parameters or generate configuration files. For more information, see Init Containers.

    2. Optional: In the Ports section, you can click Add to add container ports.

    3. Optional: In the Environments section, you can click Add to add environment variables.

      You can configure environment variables in key-value pairs. Environment variables are used to apply pod configurations to containers. For more information, see Pod variables.

    4. Optional: In the Lifecycle section, you can configure the lifecycle of the container.

      You can specify the following parameters to configure the lifecycle of the container: Start, Post Start, and Pre Stop. For more information, see Attach Handlers to Container Lifecycle Events.

      • Start: Set the command and parameter that take effect before the container starts.

      • Post Start: Specify the command that takes effect after the container starts.

      • Pre Stop: Specify the command that takes effect before the container stops.

    5. Optional: In the Volume section, configure volumes that you want to mount to the container.

      Local storage and cloud storage are supported.

      • Local storage: You can select ConfigMap, Secret, or EmptyDir from the PV Type drop-down list. Then, set the Mount Source and Container Path parameters to mount the volume to a container path. For more information, see Volumes.

      • Cloud storage: Disks and File Storage NAS (NAS) file systems are supported. For more information, see Storage overview.

  2. After you complete the container settings, click Next.

Step 3: Configure advanced settings

  1. In the Job Settings section, Configure the Job parameters.

    Parameter

    Description

    Completions

    The number of pods that must terminate with success. Default value: 1.

    Parallelism

    The number of pods that the Job must run in parallel. Default value: 1.

    Timeout

    The activeDeadlineSeconds field in the YAML file. This field specifies the duration time limit of the Job. If the Job is not complete within the duration time limit, the system attempts to terminate the Job.

    BackoffLimit

    The maximum number of attempts to recreate pods after pods fail. Default value: 6. Failed pods are recreated with an exponential back-off delay. The upper limit of the delay is 6 minutes.

    Restart

    Valid values: Never and On Failure.

  2. Optional: In the Labels,Annotations section, click Add to add labels and annotations to the pod.

  3. Click Create Now.

    After the application is deployed, you are redirected to the Complete wizard page. The resource objects of the application are displayed. On the Jobs page, you can view information about the Job you created.

What to do next

On the Jobs page, find the application that you want to manage and click its name or Details in the Actions column. On the details page of the application, you can click Scale to scale the application or click View in YAML to view the YAML file of the application.

  • Scale the application: In the upper-right corner of the application details page, click Scale to scale the application to a required number of pods.

  • View the YAML file of the application: On the application details page, click View in YAML to view the YAML file of the application.