Skip to content

Commit

Permalink
KEP 973 workload-Priority (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekko0114 authored Sep 24, 2023
1 parent f9273be commit 4aea01d
Show file tree
Hide file tree
Showing 65 changed files with 1,905 additions and 80 deletions.
7 changes: 7 additions & 0 deletions apis/kueue/v1beta1/workload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ type WorkloadSpec struct {
// The higher the value, the higher the priority.
// If priorityClassName is specified, priority must not be null.
Priority *int32 `json:"priority,omitempty"`

// priorityClassSource determines whether the priorityClass field refers to a pod PriorityClass or kueue.x-k8s.io/workloadpriorityclass.
// Workload's PriorityClass can accept the name of a pod priorityClass or a workloadPriorityClass.
// When using pod PriorityClass, a priorityClassSource field has the scheduling.k8s.io/priorityclass value.
// +kubebuilder:default=""
// +kubebuilder:validation:Enum=kueue.x-k8s.io/workloadpriorityclass;scheduling.k8s.io/priorityclass;""
PriorityClassSource string `json:"priorityClassSource,omitempty"`
}

type Admission struct {
Expand Down
56 changes: 56 additions & 0 deletions apis/kueue/v1beta1/workloadpriorityclass_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:storageversion
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:printcolumn:name="Value",JSONPath=".value",type=integer,description="Value of workloadPriorityClass's Priority"

// WorkloadPriorityClass is the Schema for the workloadPriorityClass API
type WorkloadPriorityClass struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// value represents the integer value of this workloadPriorityClass. This is the actual priority that workloads
// receive when jobs have the name of this class in their workloadPriorityClass label.
// Changing the value of workloadPriorityClass doesn't affect the priority of workloads that were already created.
Value int32 `json:"value"`

// description is an arbitrary string that usually provides guidelines on
// when this workloadPriorityClass should be used.
// +optional
Description string `json:"description,omitempty"`
}

//+kubebuilder:object:root=true

// WorkloadPriorityClassList contains a list of WorkloadPriorityClass
type WorkloadPriorityClassList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []WorkloadPriorityClass `json:"items"`
}

func init() {
SchemeBuilder.Register(&WorkloadPriorityClass{}, &WorkloadPriorityClassList{})
}
57 changes: 57 additions & 0 deletions apis/kueue/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
{{- if .Values.enableCertManager }}
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "kueue.fullname" . }}-serving-cert
{{- end }}
controller-gen.kubebuilder.io/version: v0.12.0
name: workloadpriorityclasses.kueue.x-k8s.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
name: {{ include "kueue.fullname" . }}-webhook-service
namespace: '{{ .Release.Namespace }}'
path: /convert
conversionReviewVersions:
- v1
group: kueue.x-k8s.io
names:
kind: WorkloadPriorityClass
listKind: WorkloadPriorityClassList
plural: workloadpriorityclasses
singular: workloadpriorityclass
scope: Cluster
versions:
- additionalPrinterColumns:
- description: Value of workloadPriorityClass's Priority
jsonPath: .value
name: Value
type: integer
name: v1beta1
schema:
openAPIV3Schema:
description: WorkloadPriorityClass is the Schema for the workloadPriorityClass
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
description:
description: description is an arbitrary string that usually provides
guidelines on when this workloadPriorityClass should be used.
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
value:
description: value represents the integer value of this workloadPriorityClass.
This is the actual priority that workloads receive when jobs have the
name of this class in their workloadPriorityClass label. Changing the
value of workloadPriorityClass doesn't affect the priority of workloads
that were already created.
format: int32
type: integer
required:
- value
type: object
served: true
storage: true
subresources: {}
12 changes: 12 additions & 0 deletions charts/kueue/templates/crd/kueue.x-k8s.io_workloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8219,6 +8219,18 @@ spec:
with that name. If not specified, the workload priority will be
default or zero if there is no default.
type: string
priorityClassSource:
default: ""
description: priorityClassSource determines whether the priorityClass
field refers to a pod PriorityClass or kueue.x-k8s.io/workloadpriorityclass.
Workload's PriorityClass can accept the name of a pod priorityClass
or a workloadPriorityClass. When using pod PriorityClass, a priorityClassSource
field has the scheduling.k8s.io/priorityclass value.
enum:
- kueue.x-k8s.io/workloadpriorityclass
- scheduling.k8s.io/priorityclass
- ""
type: string
queueName:
description: queueName is the name of the LocalQueue the Workload
is associated with. queueName cannot be changed while .status.admission
Expand Down
8 changes: 8 additions & 0 deletions charts/kueue/templates/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ rules:
- resourceflavors/finalizers
verbs:
- update
- apiGroups:
- kueue.x-k8s.io
resources:
- workloadpriorityclasses
verbs:
- get
- list
- watch
- apiGroups:
- kueue.x-k8s.io
resources:
Expand Down
Loading

0 comments on commit 4aea01d

Please sign in to comment.