A Job runs short-lived, one-off batch tasks and ensures that one or more pods complete successfully. You can create a Job workload in the ACS console.
Job types
Jobs are classified by the .spec.completions (required successful pods, default: 1) and .spec.parallelism (max concurrent pods, default: 1) parameters.
|
Job type |
completions |
parallelism |
Example |
Action |
|
One-off Job |
1 |
1 |
Database migration |
Starts one pod. Completes when that pod succeeds. |
|
Job with a fixed completion count |
2+ |
1 |
Start pods one after one to process a work queue |
Starts pods sequentially. Completes when the number of successful pods reaches |
|
Parallel Job with a work queue |
1 |
2+ |
A Job of this type starts multiple pods at a time. |
Runs multiple pods in parallel. Completes when all pods terminate and at least one succeeds. |
|
Parallel Job with a fixed completion count |
2+ |
2+ |
A Job of this type starts multiple pods at a time. |
Runs multiple pods in parallel. Completes when the number of successful pods reaches |
Procedure
Step 1: Configure basic application settings
-
Log on to the ACS console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of the target cluster, or click Details in the Actions column.
-
In the left-side navigation pane of the cluster management page, choose .
-
On the Jobs page, click Create from Image.
-
In the Basic Information step, configure the following settings.
Parameter
Description
Name:
The application name.
Type
Select Job.
Label
Labels that identify the application.
Annotations
Annotations for the application.
Instance Type
Select a compute type. For details about compute types, see Overview of ACS pod instances.
QoS Type
Select a Quality of Service (QoS) class.
-
After you configure the basic information, click Next.
Step 2: Configure container settings
In the Container step, configure the container image, resources, ports, environment variables, lifecycle, volumes, and logs.
To add multiple containers to the pod, click Add Container next to the Container 1 tab.
-
In the General section, complete the basic container configuration.
configuration item
Description
Image Name
-
Select an image
Click Select Image to choose the required image.
-
Container Registry Enterprise Edition: Select an Enterprise Edition image hosted in Alibaba Cloud Container Registry (ACR). You must select the region and ACR instance where the image resides. For more information about ACR, see What is Container Registry?.
-
Container Registry Personal Edition (must be activated first): Select a Personal Edition image hosted in ACR. You must select the region and ACR instance where the image resides.
-
Artifact center: Includes base OS images for containerized applications, language runtime images, and AI/big data-related images. This example uses an Nginx image from Artifact Center. For more information, see Artifact Center.
-
-
(Optional) Set the image pull policy
From the Image Pull Policy drop-down list, select a pull policy. By default, no policy is set, and Kubernetes uses IfNotPresent.
-
IfNotPresent: If the image already exists locally (previously pulled to the host), it will not be pulled again. Otherwise, the image will be pulled.
-
Always: Always pull the image during deployment or scale-out, ignoring any local copy.
-
Never: Use only the local image.
-
-
(Optional) Set an image pull secret
Click Set Image Pull Secret to securely access private images.
-
For ACR Personal Edition instances, you can pull container images by setting an image pull secret. For more information, see Manage secrets.
-
For ACR Enterprise Edition instances, you can pull images without passwords using the passwordless component. For details, see Pull ACR images without passwords.
-
Required Resources
Set resource quotas for the container.
-
CPU: Specify CPU request and limit values. By default, the request equals the limit, and billing uses the pay-as-you-go method. If you set a different limit via YAML, the request will be overwritten to match the limit. For details, see Resource specifications.
-
Memory: Specify memory request and limit values. By default, the request equals the limit, and billing uses the pay-as-you-go method. If you set a different limit via YAML, the request will be overwritten to match the limit. For details, see Resource specifications.
Interactive Session
(Optional) Configure container startup options.
-
stdin: Send console input to the container.
-
tty: Attach the standard input console as the container's console input.
NoteTypically, both stdin and tty are selected together to bind the terminal (tty) to the container's standard input (stdin). For example, an interactive program reads user input from stdin and displays output on the terminal.
Init Containers
(Optional) Select this option to create an init container.
Init containers provide a mechanism to block or delay the startup of application containers until they succeed. After successful execution, application containers in the pod start in parallel. For example, you can use init containers to check the availability of dependent services. Init containers can include utilities or installation scripts not present in the application image to initialize the runtime environment—for example, setting kernel parameters or generating configuration files. For more information, see Init Containers.
-
-
(Optional) In the Ports section, click Add to configure container ports.
configuration item
Description
Name
Specify a name for the container port.
Container Port
Specify the exposed container access port. The port number must be between 1 and 65535.
Protocol
Supported protocols are TCP and UDP.
-
(Optional) In the Environments section, click Add to configure environment variables.
You can configure environment variables for the pod using key-value pairs to add environment flags or pass configuration. For more information, see Pod Environment Variables.
Parameter
Description
Type
Set the environment variable type:
-
Custom
-
ConfigMaps
-
Secrets
-
Value/ValueFrom
-
ResourceFieldRef
ConfigMap and Secret support referencing entire files.
This example uses a Secret. When you select the Secrets type and choose a target Secret, all files in that Secret are referenced by default. After selecting Secret, enter a Variable Name and select the corresponding Secret name and key from the two drop-down lists on the right.
The corresponding YAML references the entire Secret:
envFrom: - secretRef: name: testVariable Key
Set the environment variable name.
Value/ValueFrom
Set the referenced variable value.
-
-
(Optional) In the Lifecycle section, configure the container lifecycle.
You can configure pre-start commands, post-start handlers, and pre-stop handlers for the container lifecycle. For details, see Configure lifecycle.
Parameter
Description
Start
Specify a command and its arguments to run before the container starts.
Post-start Hook
Specify a command to run after the container starts.
Pre-stop Hook
Specify a command to run before the container terminates.
-
(Optional) In the Volume section, mount volumes to the container.
-
Local storage: Mount ConfigMaps, Secrets, or temporary directories to container paths. For more information, see volumes.
-
Cloud storage: Supports cloud disks, NAS, and more. For details, see Storage overview.
-
-
(Optional) In the Log section, configure Collection Configuration and Custom Tag.
Parameter
Description
Collection Settings
-
Logstore: Creates a corresponding Logstore in Simple Log Service to store collected logs.
-
Log Path in Container (Can be set to stdout): Supports stdout and text logs.
-
Stdout: Collects standard output logs from the container.
-
Text logs: Collects logs from a specified path inside the container. This example collects all text logs under
/var/log/nginxand supports wildcard characters.
-
Custom Tags
You can also set custom tags. When configured, these tags are included with the container logs. Custom tags help you categorize logs for easier statistics and filtering during analysis.
-
-
Click Next to go to the Advanced wizard.
Step 3: Configure advanced settings
-
In the Job Settings section, configure the Job settings.
Parameter
Description
Completions
Required number of successful pods. Default value: 1.
Parallelism
Maximum concurrent pods. Default value: 1.
Timeout
Maximum duration (in seconds) for the Job. If the Job does not complete within this limit, the system terminates it.
BackoffLimit
Maximum retry count for failed pods. Default value: 6. Retries use exponential back-off capped at 6 minutes.
Restart
Only Never and On Failure are supported.
-
(Optional) In the Labels and Annotations section, click Add to set labels and annotations for the pod.
-
Click Create.
Step 4: View application information
After the Job is created, click View Details on the confirmation page to view the Job details.
Alternatively, on the Jobs page, click the Job name or Details in the Actions column.