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 |
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 |
Procedure
Step 1: Configure basic application settings
Log on to the ACS console. In the left-side navigation pane, click Clusters.
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.
In the left-side navigation pane of the details page, choose
.On the Jobs page, click Create from Image.
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.
After you complete the basic settings, click Next.
Step 2: Configure container settings
On the Container wizard page, configure the settings of containers.
NoteTo add containers, click Add Container to the right of Container1.
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.
You can use Secrets to pull images from Container Registry Personal Edition instances. For more information about how to set a Secret, see Manage Secrets.
You can pull images without using Secrets from Container Registry Enterprise Edition instances. For more information, see Pull images from a Container Registry instance without using Secrets.
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.
Notestdin 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.
Optional: In the Ports section, you can click Add to add container ports.
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.
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.
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.
After you complete the container settings, click Next.
Step 3: Configure advanced settings
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.
Optional: In the Labels,Annotations section, click Add to add labels and annotations to the pod.
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.