sigs.k8s.io/kueue@v0.6.2/site/content/en/docs/tasks/run_job_with_workload_priority.md (about)

     1  ---
     2  title: "Run job with WorkloadPriority"
     3  date: 2023-10-02
     4  weight: 8
     5  description: >
     6    Run job with WorkloadPriority, which is independent from Pod's priority
     7  ---
     8  
     9  Usually, in Kueue, workload's priority is calculated using for pod's priority for queuing and preemption.  
    10  By using a [`WorkloadPriorityClass`](/docs/concepts/workload_priority_class),
    11  you can independently manage the priority of workloads for queuing and preemption, separate from pod's priority.  
    12  
    13  This page contains instructions on how to run a job with workload priority.
    14  
    15  ## Before you begin
    16  
    17  Make sure the following conditions are met:
    18  
    19  - A Kubernetes cluster is running.
    20  - The kubectl command-line tool has communication with your cluster.
    21  - [Kueue is installed](/docs/installation).
    22  
    23  ## 0. Create WorkloadPriorityClass
    24  
    25  The WorkloadPriorityClass should be created first.
    26  
    27  ```yaml
    28  apiVersion: kueue.x-k8s.io/v1beta1
    29  kind: WorkloadPriorityClass
    30  metadata:
    31    name: sample-priority
    32  value: 10000
    33  description: "Sample priority"
    34  ```
    35  
    36  ## 1. Create Job with `kueue.x-k8s.io/priority-class` label
    37  
    38  You can specify the `WorkloadPriorityClass` by setting the label `kueue.x-k8s.io/priority-class`.
    39  This is same for other CRDs like `RayJob`.  
    40  
    41  ```yaml
    42  apiVersion: batch/v1
    43  kind: Job
    44  metadata:
    45    name: sample-job
    46    labels:
    47      kueue.x-k8s.io/queue-name: user-queue
    48      kueue.x-k8s.io/priority-class: sample-priority
    49  spec:
    50    parallelism: 3
    51    completions: 3
    52    suspend: true
    53    template:
    54      spec:
    55        containers:
    56        - name: dummy-job
    57          image: gcr.io/k8s-staging-perf-tests/sleep:latest
    58        restartPolicy: Never
    59  ```
    60  
    61  Kueue generates the following `Workload` for the Job above.
    62  The priority of workloads is utilized in queuing, preemption, and other scheduling processes in Kueue.
    63  This priority doesn't affect pod's priority.  
    64  Workload's `Priority` field is always mutable because it might be useful for the preemption.
    65  Workload's `PriorityClassSource` and `PriorityClassName` fields are immutable.
    66  
    67  ```yaml
    68  apiVersion: kueue.x-k8s.io/v1beta1
    69  kind: Workload
    70  metadata:
    71    name: job-sample-job-7f173
    72  spec:
    73    priorityClassSource: kueue.x-k8s.io/workloadpriorityclass
    74    priorityClassName: sample-priority
    75    priority: 10000
    76    queueName: user-queue
    77    podSets:
    78    - count: 3
    79      name: dummy-job
    80      template:
    81        spec:
    82          containers:
    83          - image: gcr.io/k8s-staging-perf-tests/sleep:latest
    84            name: dummy-job
    85  ```