A job is a Kubernetes workload designed for managing batch processing tasks, handling one-time or short-lived tasks. Unlike long-running services managed by Deployments or StatefulSets, a job creates one or more pods, executing them with defined start and end phases. If the task is not completed, the job retries pod execution until the target is reached.
You can set different tasks for a job as required.
Parameter | Description |
|---|---|
Workload Type | Select Job. For details about different workload types, see Workload Overview. |
Workload Name | Enter a name for the workload. Enter 1 to 63 characters starting with a lowercase letter and ending with a lowercase letter or digit. Only lowercase letters, digits, and hyphens (-) are allowed. |
Namespace | Select a namespace for the workload. The default value is default. You can also click Create Namespace to create one. For details, see Creating a Namespace. |
Pods | Enter the number of workload pods. |
Container Runtime | A CCE standard cluster uses a common runtime by default, whereas a CCE Turbo cluster supports both common and secure runtimes. For details about their differences, see Secure Runtime and Common Runtime. |
If you configured multiple containers for a pod, ensure that the ports used by each container do not conflict with each other, or the workload cannot be deployed.
Parameter | Description |
|---|---|
Container Name | Enter a name for the container. |
Pull Policy | Image update or pull policy. If you select Always, the image is pulled from the image repository each time. If you do not select Always, the existing image of the node is preferentially used. If the image does not exist, the image is pulled from the image repository. |
Image Name | Click Select Image and select the image used by the container. To use a third-party image, directly enter image path. Ensure that the image access credential can be used to access the image repository. For details, see Using Third-Party Images. |
Image Tag | Select the image tag to be deployed. |
CPU Quota |
If Request and Limit are not specified, the quota is not limited. For more information and suggestions about Request and Limit, see Configuring Container Specifications. |
Memory Quota |
If Request and Limit are not specified, the quota is not limited. For more information and suggestions about Request and Limit, see Configuring Container Specifications. |
(Optional) GPU Quota | Configurable only when the cluster contains GPU nodes and the CCE AI Suite (NVIDIA GPU) add-on has been installed.
For details about how to use GPUs in a cluster, see Default GPU Scheduling in Kubernetes. |
(Optional) Privileged Container | Programs in a privileged container have certain privileges. If this option is enabled, the container will be assigned privileges. For example, privileged containers can manipulate network devices on the host machine, modify kernel parameters, access all devices on the node. For more information, see Pod Security Standards. |
(Optional) Init Container | Whether to use the container as an init container. An init container does not support health check. An init container is a special container that runs before other app containers in a pod are started. Each pod can contain multiple containers. In addition, a pod can contain one or more init containers. Application containers in a pod are started and run only after the running of all init containers completes. For details, see Init Containers. |
(Optional) Run Option | Add run options for the container. For details, see Pod. CCE supports the following run options:
|
If the workload contains more than one pod, EVS volumes cannot be mounted.
To disable the collection of the standard output logs of the current workload, add the annotation kubernetes.AOM.log.stdout: [] in Labels and Annotations in the Advanced Settings area. For details about how to use this annotation, see Table 1.
Parameter | Description |
|---|---|
Labels and Annotations | Add labels or annotations for pods using key-value pairs. After the setting, click Confirm. For details about labels and annotations, see Configuring Labels and Annotations. |
Job Settings |
|
Network Configuration |
|
A job has the following configuration parameters:
Based on the .spec.completions and .spec.parallelism settings, jobs are classified into the following types.
Job Type | Description | .spec.completions | .spec.parallelism |
|---|---|---|---|
One-off jobs | A job creates one pod until it successfully completes. | 1 | 1 |
Jobs with a fixed completion count | A job creates one pod at a time until .spec.completions successes are reached. | > 1 | 1 |
Parallel jobs with a fixed completion count | A job creates multiple pods concurrently until .spec.completions successes are reached. | > 1 | > 1 |
Parallel jobs with a work queue | A job creates one or more pods. Each pod takes one task from the message queue, processes it, and repeats until the end of the queue is reached. Then the pod deletes the task and exits. For details, see Fine Parallel Processing Using a Work Queue. | Leave this parameter blank. | ≥ 1 |
The following is an example job, which calculates π till the 2000th digit and prints the output.
apiVersion: batch/v1kind: Jobmetadata:name: myjobspec:completions: 50 # A total of 50 pods need to run to finish a job. In this example, π is printed for 50 times.parallelism: 5 # A total of 5 pods run in parallel.backoffLimit: 5 # A maximum of 5 retries is allowed.template:spec:containers:- name: piimage: perlcommand: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]restartPolicy: Never # For a job, set this parameter to Never or OnFailure. For other controllers (such as Deployments), set this parameter to Always.imagePullSecrets:- name: default-secret
Run the job.
kubectl apply -f myjob.yaml
Command output:
job.batch/myjob created
kubectl get job
Command output:
NAME COMPLETIONS DURATION AGEmyjob 50/50 23s 3m45s
If the value of COMPLETIONS is 50/50, the job is successfully executed.
kubectl get pod
Command output:
NAME READY STATUS RESTARTS AGEmyjob-29qlw 0/1 Completed 0 4m5s...
If the status is Completed, the job is complete.
kubectl logs myjob-29qlw
Command output:
After a one-off job is created, you can perform operations listed in Table 2.
Operation | Description |
|---|---|
Viewing a YAML file | Locate the row containing the target job and choose More > View YAML to view the YAML file of the job. |
Deleting a job |
|