sigs.k8s.io/kueue@v0.6.2/apis/kueue/v1beta1/localqueue_types.go (about) 1 /* 2 Copyright 2023 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1beta1 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 "k8s.io/apimachinery/pkg/api/resource" 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 ) 24 25 // LocalQueueSpec defines the desired state of LocalQueue 26 type LocalQueueSpec struct { 27 // clusterQueue is a reference to a clusterQueue that backs this localQueue. 28 ClusterQueue ClusterQueueReference `json:"clusterQueue,omitempty"` 29 } 30 31 // ClusterQueueReference is the name of the ClusterQueue. 32 type ClusterQueueReference string 33 34 // LocalQueueStatus defines the observed state of LocalQueue 35 type LocalQueueStatus struct { 36 // PendingWorkloads is the number of Workloads in the LocalQueue not yet admitted to a ClusterQueue 37 // +optional 38 PendingWorkloads int32 `json:"pendingWorkloads"` 39 40 // reservingWorkloads is the number of workloads in this LocalQueue 41 // reserving quota in a ClusterQueue and that haven't finished yet. 42 // +optional 43 ReservingWorkloads int32 `json:"reservingWorkloads"` 44 45 // admittedWorkloads is the number of workloads in this LocalQueue 46 // admitted to a ClusterQueue and that haven't finished yet. 47 // +optional 48 AdmittedWorkloads int32 `json:"admittedWorkloads"` 49 50 // Conditions hold the latest available observations of the LocalQueue 51 // current state. 52 // +optional 53 // +listType=map 54 // +listMapKey=type 55 // +patchStrategy=merge 56 // +patchMergeKey=type 57 Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` 58 59 // flavorsReservation are the reserved quotas, by flavor currently in use by the 60 // workloads assigned to this LocalQueue. 61 // +listType=map 62 // +listMapKey=name 63 // +kubebuilder:validation:MaxItems=16 64 // +optional 65 FlavorsReservation []LocalQueueFlavorUsage `json:"flavorsReservation"` 66 67 // flavorsUsage are the used quotas, by flavor currently in use by the 68 // workloads assigned to this LocalQueue. 69 // +listType=map 70 // +listMapKey=name 71 // +kubebuilder:validation:MaxItems=16 72 // +optional 73 FlavorUsage []LocalQueueFlavorUsage `json:"flavorUsage"` 74 } 75 76 const ( 77 // LocalQueueActive indicates that the ClusterQueue that backs the LocalQueue is active and 78 // the LocalQueue can submit new workloads to its ClusterQueue. 79 LocalQueueActive string = "Active" 80 ) 81 82 type LocalQueueFlavorUsage struct { 83 // name of the flavor. 84 Name ResourceFlavorReference `json:"name"` 85 86 // resources lists the quota usage for the resources in this flavor. 87 // +listType=map 88 // +listMapKey=name 89 // +kubebuilder:validation:MaxItems=16 90 Resources []LocalQueueResourceUsage `json:"resources"` 91 } 92 93 type LocalQueueResourceUsage struct { 94 // name of the resource. 95 Name corev1.ResourceName `json:"name"` 96 97 // total is the total quantity of used quota. 98 Total resource.Quantity `json:"total,omitempty"` 99 } 100 101 // +genclient 102 // +kubebuilder:object:root=true 103 // +kubebuilder:storageversion 104 // +kubebuilder:subresource:status 105 // +kubebuilder:printcolumn:name="ClusterQueue",JSONPath=".spec.clusterQueue",type=string,description="Backing ClusterQueue" 106 // +kubebuilder:printcolumn:name="Pending Workloads",JSONPath=".status.pendingWorkloads",type=integer,description="Number of pending workloads" 107 // +kubebuilder:printcolumn:name="Admitted Workloads",JSONPath=".status.admittedWorkloads",type=integer,description="Number of admitted workloads that haven't finished yet." 108 // +kubebuilder:resource:shortName={queue,queues} 109 110 // LocalQueue is the Schema for the localQueues API 111 type LocalQueue struct { 112 metav1.TypeMeta `json:",inline"` 113 metav1.ObjectMeta `json:"metadata,omitempty"` 114 115 Spec LocalQueueSpec `json:"spec,omitempty"` 116 Status LocalQueueStatus `json:"status,omitempty"` 117 } 118 119 // +kubebuilder:object:root=true 120 121 // LocalQueueList contains a list of LocalQueue 122 type LocalQueueList struct { 123 metav1.TypeMeta `json:",inline"` 124 metav1.ListMeta `json:"metadata,omitempty"` 125 Items []LocalQueue `json:"items"` 126 } 127 128 func init() { 129 SchemeBuilder.Register(&LocalQueue{}, &LocalQueueList{}) 130 }