sigs.k8s.io/kueue@v0.6.2/apis/kueue/v1beta1/admissioncheck_types.go (about) 1 /* 2 Copyright 2022 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 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 type CheckState string 24 25 const ( 26 // CheckStateRetry means that the check cannot pass at this moment, back off (possibly 27 // allowing other to try, unblock quota) and retry. 28 // A workload having at least one check in the state, 29 // will be evicted if admitted will not be considered 30 // for admission. 31 CheckStateRetry CheckState = "Retry" 32 33 // CheckStateRejected means that the check will not pass in the near future. It is not worth 34 // to retry. 35 // NOTE: The admission behaviour is currently the same as for retry, 36 // we can consider marking the workload as "Finished" with a failure 37 // description. 38 CheckStateRejected CheckState = "Rejected" 39 40 // CheckStatePending means that the check still hasn't been performed and the state can be 41 // 1. Unknown, the condition was added by kueue and its controller was not able to evaluate it. 42 // 2. Set by its controller and reevaluated after quota is reserved. 43 CheckStatePending CheckState = "Pending" 44 45 // CheckStateReady means that the check has passed. 46 // A workload having all its checks ready, and quota reserved can begin execution. 47 CheckStateReady CheckState = "Ready" 48 ) 49 50 // AdmissionCheckSpec defines the desired state of AdmissionCheck 51 type AdmissionCheckSpec struct { 52 // controllerName is name of the controller which will actually perform 53 // the checks. This is the name with which controller identifies with, 54 // not necessarily a K8S Pod or Deployment name. Cannot be empty. 55 ControllerName string `json:"controllerName"` 56 57 // RetryDelayMinutes specifies how long to keep the workload suspended 58 // after a failed check (after it transitioned to False). 59 // After that the check state goes to "Unknown". 60 // The default is 15 min. 61 // +optional 62 // +kubebuilder:default=15 63 RetryDelayMinutes *int64 `json:"retryDelayMinutes,omitempty"` 64 65 // Parameters identifies the resource providing additional check parameters. 66 // +optional 67 Parameters *AdmissionCheckParametersReference `json:"parameters,omitempty"` 68 } 69 70 type AdmissionCheckParametersReference struct { 71 // ApiGroup is the group for the resource being referenced. 72 APIGroup string `json:"apiGroup"` 73 // Kind is the type of the resource being referenced. 74 Kind string `json:"kind"` 75 // Name is the name of the resource being referenced. 76 Name string `json:"name"` 77 } 78 79 // AdmissionCheckStatus defines the observed state of AdmissionCheck 80 type AdmissionCheckStatus struct { 81 // conditions hold the latest available observations of the AdmissionCheck 82 // current state. 83 // +optional 84 // +listType=map 85 // +listMapKey=type 86 // +patchStrategy=merge 87 // +patchMergeKey=type 88 Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` 89 } 90 91 const ( 92 // AdmissionCheckActive indicates that the controller of the admission check is 93 // ready to evaluate the checks states 94 AdmissionCheckActive string = "Active" 95 ) 96 97 // +genclient 98 // +genclient:nonNamespaced 99 // +kubebuilder:object:root=true 100 // +kubebuilder:storageversion 101 // +kubebuilder:subresource:status 102 // +kubebuilder:resource:scope=Cluster 103 104 // AdmissionCheck is the Schema for the admissionchecks API 105 type AdmissionCheck struct { 106 metav1.TypeMeta `json:",inline"` 107 metav1.ObjectMeta `json:"metadata,omitempty"` 108 109 Spec AdmissionCheckSpec `json:"spec,omitempty"` 110 Status AdmissionCheckStatus `json:"status,omitempty"` 111 } 112 113 // +kubebuilder:object:root=true 114 115 // AdmissionCheckList contains a list of AdmissionCheck 116 type AdmissionCheckList struct { 117 metav1.TypeMeta `json:",inline"` 118 metav1.ListMeta `json:"metadata,omitempty"` 119 Items []AdmissionCheck `json:"items"` 120 } 121 122 func init() { 123 SchemeBuilder.Register(&AdmissionCheck{}, &AdmissionCheckList{}) 124 }