A Job runs one-off tasks and ensures that a specified number of pods complete successfully. This document explains how Jobs work and how to create one in Container Service for Kubernetes (ACK) using the console or kubectl.
How Jobs work
Unlike Deployments, StatefulSets, and DaemonSets—which keep a target number of pods running continuously—a Job tracks successful pod completions. Configure spec.completions to set how many pods must complete successfully, and spec.parallelism to control how many pods run at the same time.
Execution types
Choose an execution type based on your task requirements:
Non-parallel (sequential)
Run one pod at a time. The Job is complete when the pod terminates successfully.
spec.completions | spec.parallelism |
|---|---|
| 1 | 1 |
Use this for one-time initialization tasks, such as database migrations.
Parallel with fixed completion count
Run multiple pods in parallel, with a fixed number of required successes. The Job is complete when spec.completions pods terminate successfully.
spec.completions | spec.parallelism |
|---|---|
| N | M (M ≤ N) |
If M = N: all N pods run in parallel, all must succeed. Use this when compute resources are sufficient.
If M < N: N pods run in parallel, but only M successes are required. Use this when you want redundancy—for example, running tasks across multiple zones where only one result is needed.
Resource-constrained parallel
When compute resources are insufficient to run N pods in parallel, limit concurrency with spec.parallelism.
spec.completions | spec.parallelism |
|---|---|
| N | M (M < N) |
M pods run at a time. As each pod completes successfully, new ones start until N succeed.
Prerequisites
Before you begin, ensure that you have:
An ACK cluster with public network access (required to pull the sample image)
A kubectl connection to the cluster (required for the kubectl method only)
To enable public network access for your cluster:
(Recommended) Enable an existing ACK cluster to access the Internet — create a public NAT gateway for the virtual private cloud (VPC) hosting the cluster. All cluster resources gain public access.
Assign static public IP addresses to nodes — nodes with public IPs can pull public images, but every node running workloads must have a public IP assigned.
Create a Job
Create a Job using the ACK console
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of the cluster you want. In the left-side pane, choose Workloads > Jobs.
On the Jobs page, click Create from Image in the upper-left corner.
In the Basic Information step, configure the basic settings, then click Next to go to the Container step.
In the General section, enter
registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latestin the Image Name field. In the Start part of the Lifecycle section, enter/bin/shin the Command field and enter["-c", "echo 'starting...'; COUNTER=0; while [ $COUNTER -lt 5 ]; do sleep 2; COUNTER=$((COUNTER+1)); echo $COUNTER; done; echo 'finished'; exit 0"]in the Parameter field, as shown in the following figure. Then click Next to go to the Advanced step.ImportantPulling the
registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latestimage requires Internet access. If you kept the default value for Configure SNAT for VPC when creating the cluster, the cluster can already access the Internet. For existing clusters, see Enable an existing ACK cluster to access the Internet.
In the Advanced step, configure the Job Settings parameters. In this example, Completions is set to 2. Then click Create.
Parameter Description Completions The number of pods that must terminate successfully. Corresponds to spec.completions.Parallelism The number of pods that can run in parallel. Corresponds to spec.parallelism.Timeout The maximum duration for the Job, in seconds. Corresponds to spec.activeDeadlineSeconds. Default:600. If the Job exceeds this duration, it terminates regardless of how many pods have succeeded.BackoffLimit The maximum number of pod failures before the Job is marked as failed. Corresponds to spec.backoffLimit. Default:6.Restart The pod restart policy. Corresponds to template.spec.restartPolicy. Options: Never (restart the existing pod without creating a new one; does not count towardspec.backoffLimit) or On Failure (create a new pod to replace the failed one).Pod Labels Labels added to each pod. ACK adds app:<application-name>by default.Pod Annotations Annotations added to each pod. Some ACK features use annotations for configuration. 
After the Job is created, view its logs in the ACK console. The two pods created by the Job produce identical output.

Create a Job using kubectl
Connect to the cluster using kubectl before proceeding. See Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.
Create a file named
job.yamlwith the following content:apiVersion: batch/v1 kind: Job metadata: name: example-job spec: completions: 2 # Stop the Job after two pods terminate successfully. parallelism: 1 # Run only one pod at a time. template: spec: containers: - name: counter image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest command: - /bin/sh - -c - | echo "starting..."; COUNTER=0; while [ $COUNTER -lt 5 ]; do sleep 2; COUNTER=$((COUNTER+1)); echo "${COUNTER}"; done; echo "finished"; exit 0 restartPolicy: NeverApply the manifest:
kubectl apply -f job.yamlExpected output:
job.batch/example-job createdAfter 15 seconds, check the Job status:
kubectl get job example-jobThe output shows one pod has succeeded and the Job is still running:
NAME STATUS COMPLETIONS DURATION AGE example-job Running 1/2 16s 16sAfter 40 seconds, check the Job status again:
kubectl get job example-jobThe output shows the Job is complete:
NAME STATUS COMPLETIONS DURATION AGE example-job Complete 2/2 27s 37sView the logs from all pods:
kubectl logs -l job-name=example-jobExpected output (two identical sets, one from each pod):
starting... 1 2 3 4 5 finished starting... 1 2 3 4 5 finished
What's next
Create a CronJob — schedule a Job to run on a recurring basis.
FAQ about workloads — resolve common issues when creating workloads.
Pod troubleshooting — diagnose and fix pod exceptions.