Run A Kubernetes Job
This page shows you how to run a Job in a Kubernetes cluster with Kueue enabled.
The intended audience for this page are batch users.
Before you begin
Make sure the following conditions are met:
- A Kubernetes cluster is running.
- The kubectl command-line tool has communication with your cluster.
- Kueue is installed.
- The cluster has quotas configured.
The following picture shows all the concepts you will interact with in this tutorial:
0. Identify the queues available in your namespace
Run the following command to list the LocalQueues
available in your namespace.
The output is similar to the following:
The ClusterQueue defines the quotas for the Queue.
1. Define the Job
Running a Job in Kueue is similar to running a Job in a Kubernetes cluster without Kueue. However, you must consider the following differences:
- You should create the Job in a suspended state, as Kueue will decide when it’s the best time to start the Job.
- You have to set the Queue you want to submit the Job to. Use the
kueue.x-k8s.io/queue-name
label. - You should include the resource requests for each Job Pod.
Here is a sample Job with three Pods that just sleep for a few seconds.
2. Run the Job
You can run the Job with the following command:
Internally, Kueue will create a corresponding Workload for this Job with a matching name.
The output will be similar to the following:
3. (Optional) Monitor the status of the workload
You can see the Workload status with the following command:
If the ClusterQueue doesn’t have enough quota to run the Workload, the output will be similar to the following:
When the ClusterQueue has enough quota to run the Workload, it will admit the Workload. To see if the Workload was admitted, run the following command:
The output is similar to the following:
To view the event for the Workload admission, run the following command:
The output is similar to the following:
To continue monitoring the Workload progress, you can run the following command:
Once the Workload has finished running, the output is similar to the following:
To review more details about the Job status, run the following command:
The output is similar to the following:
Since events have a timestamp with a resolution of seconds, the events might be listed in a slightly different order from which they actually occurred.
Partial admission
Kueue provides the ability for a batch user to create Jobs that ideally will run with a parallelism P0
but can accept a smaller parallelism, Pn
, if the Job dose not fit within the available quota.
Kueue will only attempt to decrease the parallelism after both borrowing and preemption was taken into account in the admission process, and none of them are feasible.
To allow partial admission you can provide the minimum acceptable parallelism Pmin
in kueue.x-k8s.io/job-min-parallelism
annotation of the Job, Pn
should be grater that 0 and less that P0
. When a Job is partially admitted its parallelism will be set to Pn
, Pn
will be set to the maximum acceptable value between Pmin
and P0
. The Job’s completions count will not be changed.
For example, a Job defined by the following manifest:
When queued in a ClusterQueue with only 9 CPUs available, it will be admitted with parallelism=9
. Note that the number of completions doesn’t change.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.