generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 528
/
types.go
197 lines (155 loc) · 7.19 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
Copyright 2020 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 v1alpha1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/scheduler-plugins/apis/scheduling"
)
// ElasticQuota sets elastic quota restrictions per namespace
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName={eq,eqs}
// +kubebuilder:subresource:status
// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/scheduler-plugins/pull/52"
type ElasticQuota struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// ElasticQuotaSpec defines the Min and Max for Quota.
// +optional
Spec ElasticQuotaSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// ElasticQuotaStatus defines the observed use.
// +optional
Status ElasticQuotaStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// ElasticQuotaSpec defines the Min and Max for Quota.
type ElasticQuotaSpec struct {
// Min is the set of desired guaranteed limits for each named resource.
// +optional
Min v1.ResourceList `json:"min,omitempty" protobuf:"bytes,1,rep,name=min, casttype=ResourceList,castkey=ResourceName"`
// Max is the set of desired max limits for each named resource. The usage of max is based on the resource configurations of
// successfully scheduled pods.
// +optional
Max v1.ResourceList `json:"max,omitempty" protobuf:"bytes,2,rep,name=max, casttype=ResourceList,castkey=ResourceName"`
}
// ElasticQuotaStatus defines the observed use.
type ElasticQuotaStatus struct {
// Used is the current observed total usage of the resource in the namespace.
// +optional
Used v1.ResourceList `json:"used,omitempty" protobuf:"bytes,1,rep,name=used,casttype=ResourceList,castkey=ResourceName"`
}
// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ElasticQuotaList is a list of ElasticQuota items.
type ElasticQuotaList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is a list of ElasticQuota objects.
Items []ElasticQuota `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// PodGroupPhase is the phase of a pod group at the current time.
type PodGroupPhase string
// These are the valid phase of podGroups.
const (
// PodGroupPending means the pod group has been accepted by the system, but scheduler can not allocate
// enough resources to it.
PodGroupPending PodGroupPhase = "Pending"
// PodGroupRunning means the `spec.minMember` pods of the pod group are in running phase.
PodGroupRunning PodGroupPhase = "Running"
// PodGroupPreScheduling means all pods of the pod group have enqueued and are waiting to be scheduled.
PodGroupPreScheduling PodGroupPhase = "PreScheduling"
// PodGroupScheduling means partial pods of the pod group have been scheduled and are in running phase
// but the number of running pods has not reached the `spec.minMember` pods of PodGroups.
PodGroupScheduling PodGroupPhase = "Scheduling"
// PodGroupScheduled means the `spec.minMember` pods of the pod group have been scheduled and are in running phase.
PodGroupScheduled PodGroupPhase = "Scheduled"
// PodGroupUnknown means a part of `spec.minMember` pods of the pod group have been scheduled but the others can not
// be scheduled due to, e.g. not enough resource; scheduler will wait for related controllers to recover them.
PodGroupUnknown PodGroupPhase = "Unknown"
// PodGroupFinished means the `spec.minMember` pods of the pod group are successfully finished.
PodGroupFinished PodGroupPhase = "Finished"
// PodGroupFailed means at least one of `spec.minMember` pods have failed.
PodGroupFailed PodGroupPhase = "Failed"
// PodGroupLabel is the default label of coscheduling
PodGroupLabel = scheduling.GroupName + "/pod-group"
)
// PodGroup is a collection of Pod; used for batch workload.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName={pg,pgs}
// +kubebuilder:subresource:status
// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/scheduler-plugins/pull/50"
type PodGroup struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the pod group.
// +optional
Spec PodGroupSpec `json:"spec,omitempty"`
// Status represents the current information about a pod group.
// This data may not be up to date.
// +optional
Status PodGroupStatus `json:"status,omitempty"`
}
// PodGroupSpec represents the template of a pod group.
type PodGroupSpec struct {
// MinMember defines the minimal number of members/tasks to run the pod group;
// if there's not enough resources to start all tasks, the scheduler
// will not start anyone.
MinMember int32 `json:"minMember,omitempty"`
// MinResources defines the minimal resource of members/tasks to run the pod group;
// if there's not enough resources to start all tasks, the scheduler
// will not start anyone.
MinResources v1.ResourceList `json:"minResources,omitempty"`
// ScheduleTimeoutSeconds defines the maximal time of members/tasks to wait before run the pod group;
ScheduleTimeoutSeconds *int32 `json:"scheduleTimeoutSeconds,omitempty"`
}
// PodGroupStatus represents the current state of a pod group.
type PodGroupStatus struct {
// Current phase of PodGroup.
Phase PodGroupPhase `json:"phase,omitempty"`
// OccupiedBy marks the workload (e.g., deployment, statefulset) UID that occupy the podgroup.
// It is empty if not initialized.
OccupiedBy string `json:"occupiedBy,omitempty"`
// The number of actively running pods.
// +optional
Scheduled int32 `json:"scheduled,omitempty"`
// The number of actively running pods.
// +optional
Running int32 `json:"running,omitempty"`
// The number of pods which reached phase Succeeded.
// +optional
Succeeded int32 `json:"succeeded,omitempty"`
// The number of pods which reached phase Failed.
// +optional
Failed int32 `json:"failed,omitempty"`
// ScheduleStartTime of the group
ScheduleStartTime metav1.Time `json:"scheduleStartTime,omitempty"`
}
// +kubebuilder:object:root=true
// PodGroupList is a collection of pod groups.
type PodGroupList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// Items is the list of PodGroup
Items []PodGroup `json:"items"`
}