Setup a Job Admission Policy
This page shows how you can set up for Kueue a Job Admission Policy using the Kubernetes Validating Admission Policy, based on the Common Expression Language (CEL).
Before you begin
Ensure the following conditions are met:
- A Kubernetes cluster is running.
- The
ValidatingAdmissionPolicy
feature gate is enabled. In Kubernetes 1.30 or newer, the feature gate is enabled by default. - The kubectl command-line tool can communicate with your cluster.
- Kueue is installed.
Example
The example below shows you how to set up a Job Admission Policy to reject early all Job or JobSets
without the queue-name if sent to a namespace labeled as a kueue-managed
namespace.
You should set manageJobsWithoutQueueName
to false
in the Kueue Configuration to let an admin
to execute Jobs in any namespace that is not labeled as kueue-managed
. Jobs sent to unlabeled namespaces aren’t rejected, or managed
by Kueue.
To create the policy, download the above file and run the following command:
Then, apply the validating admission policy to the namespace by creating a ValidatingAdmissionPolicyBinding
. The policy binding links the namespaces to the defined admission policy and it instructs Kubernetes how to respond to the validation outcome.
The following is an example of a policy binding:
To create the binding, download the above file and run the following command:
Run the following command to label each namespace where you want this policy to be enforced:
Now, when you try to create a Job
or a JobSet
without the kueue.x-k8s.io/queue-name
label or value in any namespace
that is labeled as kueue-managed
, the error message will be similar to the following:
Handling of Parent/Child Relationships
One complication of this approach is that when a Workload is admitted, it may create child resources
of Kinds that are also managed by Kueue. These children are not required to have the queue-name label,
because their admission is implied by the admission of their parent. In the example policy, the exclude-jobset-owned
matchCondition
ensures that a child Job
that is owned by a parent JobSet
will not be denied admission.
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.