Skip to content

Commit d6b73af

Browse files
authored
Copy v1beta1 as v1beta2 (#7304)
* Copy v1beta1 as v1beta2 * Register v1beta2 in main.go
1 parent c1a7dd3 commit d6b73af

File tree

167 files changed

+38908
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+38908
-1
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
Copyright 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 v1beta2
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 this state will be evicted if admitted and
29+
// will not be considered for admission while the check is in this state.
30+
CheckStateRetry CheckState = "Retry"
31+
32+
// CheckStateRejected means that the check will not pass in the near future. It is not worth
33+
// to retry.
34+
// A workload having at least one check in this state will be evicted if admitted and deactivated.
35+
CheckStateRejected CheckState = "Rejected"
36+
37+
// CheckStatePending means that the check still hasn't been performed and the state can be
38+
// 1. Unknown, the condition was added by kueue and its controller was not able to evaluate it.
39+
// 2. Set by its controller and reevaluated after quota is reserved.
40+
CheckStatePending CheckState = "Pending"
41+
42+
// CheckStateReady means that the check has passed.
43+
// A workload having all its checks ready, and quota reserved can begin execution.
44+
CheckStateReady CheckState = "Ready"
45+
)
46+
47+
// AdmissionCheckSpec defines the desired state of AdmissionCheck
48+
type AdmissionCheckSpec struct {
49+
// controllerName identifies the controller that processes the AdmissionCheck,
50+
// not necessarily a Kubernetes Pod or Deployment name. Cannot be empty.
51+
// +kubebuilder:validation:Required
52+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="field is immutable"
53+
ControllerName string `json:"controllerName"`
54+
55+
// retryDelayMinutes specifies how long to keep the workload suspended after
56+
// a failed check (after it transitioned to False). When the delay period has passed, the check
57+
// state goes to "Unknown". The default is 15 min.
58+
// +optional
59+
// +kubebuilder:default=15
60+
// Deprecated: retryDelayMinutes has already been deprecated since v0.8 and will be removed in v1beta2.
61+
RetryDelayMinutes *int64 `json:"retryDelayMinutes,omitempty"`
62+
63+
// parameters identifies a configuration with additional parameters for the
64+
// check.
65+
// +optional
66+
Parameters *AdmissionCheckParametersReference `json:"parameters,omitempty"`
67+
}
68+
69+
type AdmissionCheckParametersReference struct {
70+
// apiGroup is the group for the resource being referenced.
71+
// +kubebuilder:validation:MaxLength=253
72+
// +kubebuilder:validation:Pattern="^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"
73+
APIGroup string `json:"apiGroup"`
74+
// kind is the type of the resource being referenced.
75+
// +kubebuilder:validation:MaxLength=63
76+
// +kubebuilder:validation:Pattern="^(?i)[a-z]([-a-z0-9]*[a-z0-9])?$"
77+
Kind string `json:"kind"`
78+
// name is the name of the resource being referenced.
79+
// +kubebuilder:validation:MaxLength=63
80+
// +kubebuilder:validation:Pattern="^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
81+
Name string `json:"name"`
82+
}
83+
84+
// AdmissionCheckStatus defines the observed state of AdmissionCheck
85+
type AdmissionCheckStatus struct {
86+
// conditions hold the latest available observations of the AdmissionCheck
87+
// current state.
88+
// +optional
89+
// +listType=map
90+
// +listMapKey=type
91+
// +patchStrategy=merge
92+
// +patchMergeKey=type
93+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
94+
}
95+
96+
const (
97+
// AdmissionCheckActive indicates that the controller of the admission check is
98+
// ready to evaluate the checks states
99+
AdmissionCheckActive string = "Active"
100+
)
101+
102+
// +genclient
103+
// +genclient:nonNamespaced
104+
// +kubebuilder:object:root=true
105+
// +kubebuilder:subresource:status
106+
// +kubebuilder:resource:scope=Cluster
107+
108+
// AdmissionCheck is the Schema for the admissionchecks API
109+
type AdmissionCheck struct {
110+
metav1.TypeMeta `json:",inline"`
111+
// metadata is the metadata of the AdmissionCheck.
112+
metav1.ObjectMeta `json:"metadata,omitempty"`
113+
114+
// spec is the specification of the AdmissionCheck.
115+
Spec AdmissionCheckSpec `json:"spec,omitempty"`
116+
117+
// status is the status of the AdmissionCheck.
118+
Status AdmissionCheckStatus `json:"status,omitempty"`
119+
}
120+
121+
// +kubebuilder:object:root=true
122+
123+
// AdmissionCheckList contains a list of AdmissionCheck
124+
type AdmissionCheckList struct {
125+
metav1.TypeMeta `json:",inline"`
126+
metav1.ListMeta `json:"metadata,omitempty"`
127+
Items []AdmissionCheck `json:"items"`
128+
}
129+
130+
func init() {
131+
SchemeBuilder.Register(&AdmissionCheck{}, &AdmissionCheckList{})
132+
}

0 commit comments

Comments
 (0)