volcano.sh/apis@v1.8.2/pkg/apis/scheduling/v1beta1/types.go (about) 1 /* 2 Copyright 2019 The Volcano 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 v1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 ) 23 24 // PodGroupPhase is the phase of a pod group at the current time. 25 type PodGroupPhase string 26 27 // QueueState is state type of queue. 28 type QueueState string 29 30 const ( 31 // QueueStateOpen indicate `Open` state of queue 32 QueueStateOpen QueueState = "Open" 33 // QueueStateClosed indicate `Closed` state of queue 34 QueueStateClosed QueueState = "Closed" 35 // QueueStateClosing indicate `Closing` state of queue 36 QueueStateClosing QueueState = "Closing" 37 // QueueStateUnknown indicate `Unknown` state of queue 38 QueueStateUnknown QueueState = "Unknown" 39 ) 40 41 // These are the valid phase of podGroups. 42 const ( 43 // PodGroupPending means the pod group has been accepted by the system, but scheduler can not allocate 44 // enough resources to it. 45 PodGroupPending PodGroupPhase = "Pending" 46 47 // PodGroupRunning means `spec.minMember` pods of PodGroup has been in running phase. 48 PodGroupRunning PodGroupPhase = "Running" 49 50 // PodGroupUnknown means part of `spec.minMember` pods are running but the other part can not 51 // be scheduled, e.g. not enough resource; scheduler will wait for related controller to recover it. 52 PodGroupUnknown PodGroupPhase = "Unknown" 53 54 // PodGroupInqueue means controllers can start to create pods, 55 // is a new state between PodGroupPending and PodGroupRunning 56 PodGroupInqueue PodGroupPhase = "Inqueue" 57 58 // PodGroupCompleted means all the pods of PodGroup are completed 59 PodGroupCompleted PodGroupPhase = "Completed" 60 ) 61 62 type PodGroupConditionType string 63 64 const ( 65 // PodGroupUnschedulableType is Unschedulable event type 66 PodGroupUnschedulableType PodGroupConditionType = "Unschedulable" 67 68 // PodGroupScheduled is scheduled event type 69 PodGroupScheduled PodGroupConditionType = "Scheduled" 70 ) 71 72 type PodGroupConditionDetail string 73 74 const ( 75 // PodGroupReady is that PodGroup has reached scheduling restriction 76 PodGroupReady PodGroupConditionDetail = "pod group is ready" 77 // PodGroupNotReady is that PodGroup has not yet reached the scheduling restriction 78 PodGroupNotReady PodGroupConditionDetail = "pod group is not ready" 79 ) 80 81 // PodGroupCondition contains details for the current state of this pod group. 82 type PodGroupCondition struct { 83 // Type is the type of the condition 84 Type PodGroupConditionType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type"` 85 86 // Status is the status of the condition. 87 Status v1.ConditionStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"` 88 89 // The ID of condition transition. 90 TransitionID string `json:"transitionID,omitempty" protobuf:"bytes,3,opt,name=transitionID"` 91 92 // Last time the phase transitioned from another to current phase. 93 // +optional 94 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"` 95 96 // Unique, one-word, CamelCase reason for the phase's last transition. 97 // +optional 98 Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"` 99 100 // Human-readable message indicating details about last transition. 101 // +optional 102 Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"` 103 } 104 105 const ( 106 // PodFailedReason is probed if pod of PodGroup failed 107 PodFailedReason string = "PodFailed" 108 109 // PodDeletedReason is probed if pod of PodGroup deleted 110 PodDeletedReason string = "PodDeleted" 111 112 // NotEnoughResourcesReason is probed if there're not enough resources to schedule pods 113 NotEnoughResourcesReason string = "NotEnoughResources" 114 115 // NotEnoughPodsReason is probed if there're not enough tasks compared to `spec.minMember` 116 NotEnoughPodsReason string = "NotEnoughTasks" 117 118 // NotEnoughPodsOfTaskReason is probed if there're not enough pods of task compared to `spec.minTaskMember` 119 NotEnoughPodsOfTaskReason string = "NotEnoughPodsOfTask" 120 ) 121 122 // QueueEvent represent the phase of queue. 123 type QueueEvent string 124 125 const ( 126 // QueueOutOfSyncEvent is triggered if PodGroup/Queue were updated 127 QueueOutOfSyncEvent QueueEvent = "OutOfSync" 128 // QueueCommandIssuedEvent is triggered if a command is raised by user 129 QueueCommandIssuedEvent QueueEvent = "CommandIssued" 130 ) 131 132 // QueueAction is the action that queue controller will take according to the event. 133 type QueueAction string 134 135 const ( 136 // SyncQueueAction is the action to sync queue status. 137 SyncQueueAction QueueAction = "SyncQueue" 138 // OpenQueueAction is the action to open queue 139 OpenQueueAction QueueAction = "OpenQueue" 140 // CloseQueueAction is the action to close queue 141 CloseQueueAction QueueAction = "CloseQueue" 142 ) 143 144 // +genclient 145 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 146 // +kubebuilder:object:root=true 147 // +kubebuilder:resource:path=podgroups,shortName=pg;podgroup-v1beta1 148 // +kubebuilder:printcolumn:name="STATUS",type=string,JSONPath=`.status.phase` 149 // +kubebuilder:printcolumn:name="minMember",type=integer,JSONPath=`.spec.minMember` 150 // +kubebuilder:printcolumn:name="RUNNINGS",type=integer,JSONPath=`.status.running` 151 // +kubebuilder:printcolumn:name="AGE",type=date,JSONPath=`.metadata.creationTimestamp` 152 // +kubebuilder:printcolumn:name="QUEUE",type=string,priority=1,JSONPath=`.spec.queue` 153 154 // PodGroup is a collection of Pod; used for batch workload. 155 type PodGroup struct { 156 metav1.TypeMeta `json:",inline"` 157 158 // +optional 159 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 160 161 // Specification of the desired behavior of the pod group. 162 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status 163 // +optional 164 Spec PodGroupSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 165 166 // Status represents the current information about a pod group. 167 // This data may not be up to date. 168 // +optional 169 Status PodGroupStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 170 } 171 172 // PodGroupSpec represents the template of a pod group. 173 type PodGroupSpec struct { 174 // MinMember defines the minimal number of members/tasks to run the pod group; 175 // if there's not enough resources to start all tasks, the scheduler 176 // will not start anyone. 177 MinMember int32 `json:"minMember,omitempty" protobuf:"bytes,1,opt,name=minMember"` 178 179 // MinTaskMember defines the minimal number of pods to run each task in the pod group; 180 // if there's not enough resources to start each task, the scheduler 181 // will not start anyone. 182 MinTaskMember map[string]int32 `json:"minTaskMember,omitempty" protobuf:"bytes,1,opt,name=minTaskMember"` 183 184 // Queue defines the queue to allocate resource for PodGroup; if queue does not exist, 185 // the PodGroup will not be scheduled. Defaults to `default` Queue with the lowest weight. 186 // +optional 187 Queue string `json:"queue,omitempty" protobuf:"bytes,2,opt,name=queue"` 188 189 // If specified, indicates the PodGroup's priority. "system-node-critical" and 190 // "system-cluster-critical" are two special keywords which indicate the 191 // highest priorities with the former being the highest priority. Any other 192 // name must be defined by creating a PriorityClass object with that name. 193 // If not specified, the PodGroup priority will be default or zero if there is no 194 // default. 195 // +optional 196 PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,3,opt,name=priorityClassName"` 197 198 // MinResources defines the minimal resource of members/tasks to run the pod group; 199 // if there's not enough resources to start all tasks, the scheduler 200 // will not start anyone. 201 MinResources *v1.ResourceList `json:"minResources,omitempty" protobuf:"bytes,4,opt,name=minResources"` 202 } 203 204 // PodGroupStatus represents the current state of a pod group. 205 type PodGroupStatus struct { 206 // Current phase of PodGroup. 207 Phase PodGroupPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase"` 208 209 // The conditions of PodGroup. 210 // +optional 211 Conditions []PodGroupCondition `json:"conditions,omitempty" protobuf:"bytes,2,opt,name=conditions"` 212 213 // The number of actively running pods. 214 // +optional 215 Running int32 `json:"running,omitempty" protobuf:"bytes,3,opt,name=running"` 216 217 // The number of pods which reached phase Succeeded. 218 // +optional 219 Succeeded int32 `json:"succeeded,omitempty" protobuf:"bytes,4,opt,name=succeeded"` 220 221 // The number of pods which reached phase Failed. 222 // +optional 223 Failed int32 `json:"failed,omitempty" protobuf:"bytes,5,opt,name=failed"` 224 } 225 226 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 227 // +kubebuilder:object:root=true 228 229 // PodGroupList is a collection of pod groups. 230 type PodGroupList struct { 231 metav1.TypeMeta `json:",inline"` 232 // Standard list metadata 233 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata 234 // +optional 235 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 236 237 // items is the list of PodGroup 238 Items []PodGroup `json:"items" protobuf:"bytes,2,rep,name=items"` 239 } 240 241 const ( 242 // DefaultQueue constant stores the name of the queue as "default" 243 DefaultQueue = "default" 244 ) 245 246 // +genclient 247 // +genclient:nonNamespaced 248 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 249 // +kubebuilder:object:root=true 250 // +kubebuilder:resource:path=queues,scope=Cluster,shortName=q;queue-v1beta1 251 // +kubebuilder:subresource:status 252 253 // Queue is a queue of PodGroup. 254 type Queue struct { 255 metav1.TypeMeta `json:",inline"` 256 257 // +optional 258 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 259 260 // Specification of the desired behavior of the queue. 261 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status 262 // +optional 263 Spec QueueSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 264 265 // The status of queue. 266 // +optional 267 Status QueueStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 268 } 269 270 // Guarantee represents configuration of queue resource reservation 271 type Guarantee struct { 272 // The amount of cluster resource reserved for queue. Just set either `percentage` or `resource` 273 // +optional 274 Resource v1.ResourceList `json:"resource,omitempty" protobuf:"bytes,3,opt,name=resource"` 275 } 276 277 // Reservation represents current condition about resource reservation 278 type Reservation struct { 279 // Nodes are Locked nodes for queue 280 // +optional 281 Nodes []string `json:"nodes,omitempty" protobuf:"bytes,1,opt,name=nodes"` 282 // Resource is a list of total idle resource in locked nodes. 283 // +optional 284 Resource v1.ResourceList `json:"resource,omitempty" protobuf:"bytes,2,opt,name=resource"` 285 } 286 287 // QueueStatus represents the status of Queue. 288 type QueueStatus struct { 289 // State is state of queue 290 State QueueState `json:"state,omitempty" protobuf:"bytes,1,opt,name=state"` 291 292 // The number of 'Unknown' PodGroup in this queue. 293 Unknown int32 `json:"unknown,omitempty" protobuf:"bytes,2,opt,name=unknown"` 294 // The number of 'Pending' PodGroup in this queue. 295 Pending int32 `json:"pending,omitempty" protobuf:"bytes,3,opt,name=pending"` 296 // The number of 'Running' PodGroup in this queue. 297 Running int32 `json:"running,omitempty" protobuf:"bytes,4,opt,name=running"` 298 // The number of `Inqueue` PodGroup in this queue. 299 Inqueue int32 `json:"inqueue,omitempty" protobuf:"bytes,5,opt,name=inqueue"` 300 // The number of `Completed` PodGroup in this queue. 301 Completed int32 `json:"completed,omitempty" protobuf:"bytes,6,opt,name=completed"` 302 303 // Reservation is the profile of resource reservation for queue 304 Reservation Reservation `json:"reservation,omitempty" protobuf:"bytes,7,opt,name=reservation"` 305 306 // Allocated is allocated resources in queue 307 Allocated v1.ResourceList `json:"allocated" protobuf:"bytes,8,opt,name=allocated"` 308 } 309 310 // CluterSpec represents the template of Cluster 311 type Cluster struct { 312 Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` 313 Weight int32 `json:"weight,omitempty" protobuf:"bytes,2,opt,name=weight"` 314 Capacity v1.ResourceList `json:"capacity,omitempty" protobuf:"bytes,3,opt,name=capacity"` 315 } 316 317 // Affinity is a group of affinity scheduling rules. 318 type Affinity struct { 319 // Describes nodegroup affinity scheduling rules for the queue(e.g. putting pods of the queue in the nodes of the nodegroup) 320 // +optional 321 NodeGroupAffinity *NodeGroupAffinity `json:"nodeGroupAffinity,omitempty" protobuf:"bytes,1,opt,name=nodeGroupAffinity"` 322 323 // Describes nodegroup anti-affinity scheduling rules for the queue(e.g. avoid putting pods of the queue in the nodes of the nodegroup). 324 // +optional 325 NodeGroupAntiAffinity *NodeGroupAntiAffinity `json:"nodeGroupAntiAffinity,omitempty" protobuf:"bytes,2,opt,name=nodeGroupAntiAffinity"` 326 } 327 328 type NodeGroupAffinity struct { 329 // +optional 330 RequiredDuringSchedulingIgnoredDuringExecution []string `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,1,opt,name=requiredDuringSchedulingIgnoredDuringExecution"` 331 // +optional 332 PreferredDuringSchedulingIgnoredDuringExecution []string `json:"preferredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,2,rep,name=preferredDuringSchedulingIgnoredDuringExecution"` 333 } 334 335 type NodeGroupAntiAffinity struct { 336 // +optional 337 RequiredDuringSchedulingIgnoredDuringExecution []string `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,1,opt,name=requiredDuringSchedulingIgnoredDuringExecution"` 338 // +optional 339 PreferredDuringSchedulingIgnoredDuringExecution []string `json:"preferredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,2,rep,name=preferredDuringSchedulingIgnoredDuringExecution"` 340 } 341 342 // QueueSpec represents the template of Queue. 343 type QueueSpec struct { 344 Weight int32 `json:"weight,omitempty" protobuf:"bytes,1,opt,name=weight"` 345 Capability v1.ResourceList `json:"capability,omitempty" protobuf:"bytes,2,opt,name=capability"` 346 347 // Reclaimable indicate whether the queue can be reclaimed by other queue 348 Reclaimable *bool `json:"reclaimable,omitempty" protobuf:"bytes,3,opt,name=reclaimable"` 349 350 // extendCluster indicate the jobs in this Queue will be dispatched to these clusters. 351 ExtendClusters []Cluster `json:"extendClusters,omitempty" protobuf:"bytes,4,opt,name=extendClusters"` 352 353 // Guarantee indicate configuration about resource reservation 354 Guarantee Guarantee `json:"guarantee,omitempty" protobuf:"bytes,5,opt,name=guarantee"` 355 356 // If specified, the pod owned by the queue will be scheduled with constraint 357 // +optional 358 Affinity *Affinity `json:"affinity,omitempty" protobuf:"bytes,6,opt,name=affinity"` 359 360 // Type define the type of queue 361 Type string `json:"type,omitempty" protobuf:"bytes,7,opt,name=type"` 362 } 363 364 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 365 // +kubebuilder:object:root=true 366 367 // QueueList is a collection of queues. 368 type QueueList struct { 369 metav1.TypeMeta `json:",inline"` 370 // Standard list metadata 371 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata 372 // +optional 373 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 374 375 // items is the list of PodGroup 376 Items []Queue `json:"items" protobuf:"bytes,2,rep,name=items"` 377 }