Skip to content

Commit 55250ac

Browse files
author
Binbin Zou
committed
vqa api init
1 parent 12d8edc commit 55250ac

24 files changed

+1530
-23
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ git clone https://github.com/volcano-sh/apis.git
1212
## generate
1313

1414
```shell
15-
bash ./hack/generate-groups.sh all volcano.sh/apis/pkg/client volcano.sh/apis/pkg/apis "batch:v1alpha1 bus:v1alpha1 nodeinfo:v1alpha1 scheduling:v1beta1" --go-header-file ./hack/boilerplate.go.txt
15+
bash ./hack/generate-groups.sh all volcano.sh/apis/pkg/client volcano.sh/apis/pkg/apis "batch:v1alpha1 bus:v1alpha1 flow:v1alpha1 nodeinfo:v1alpha1 scheduling:v1beta1 autoscaling:v1alpha1" --go-header-file ./hack/boilerplate.go.txt
1616
```

pkg/apis/autoscaling/v1alpha1/doc.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2021 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 v1alpha1 contains API Schema definitions for the batch v1alpha1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=autoscaling.volcano.sh
20+
// +k8s:deepcopy-gen=package
21+
package v1alpha1
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright 2017 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 v1alpha1
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2017 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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/runtime"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
)
24+
25+
var (
26+
// SchemeBuilder points to a list of functions added to Scheme.
27+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
28+
// AddToScheme applies all the stored functions to the scheme.
29+
AddToScheme = SchemeBuilder.AddToScheme
30+
)
31+
32+
// GroupName is the group name used in this package.
33+
const GroupName = "autoscaling.volcano.sh"
34+
35+
// SchemeGroupVersion is the group version used to register these objects.
36+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
37+
38+
// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
39+
func Resource(resource string) schema.GroupResource {
40+
return SchemeGroupVersion.WithResource(resource).GroupResource()
41+
}
42+
43+
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
44+
func addKnownTypes(scheme *runtime.Scheme) error {
45+
scheme.AddKnownTypes(SchemeGroupVersion,
46+
&VerticalQueueAutoscaler{},
47+
&VerticalQueueAutoscalerList{},
48+
)
49+
50+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
51+
return nil
52+
}

pkg/apis/autoscaling/v1alpha1/vqa.go

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
/*
2+
Copyright 2018 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 v1alpha1
18+
19+
import (
20+
v2 "k8s.io/api/autoscaling/v2"
21+
corev1 "k8s.io/api/core/v1"
22+
"k8s.io/apimachinery/pkg/api/resource"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
)
25+
26+
type VerticalQueueAutoscalerType string
27+
type StepType string
28+
type Condition string
29+
30+
const (
31+
ResourceVQARatio corev1.ResourceName = "ratio"
32+
VerticalQueueAutoscalerTidalType VerticalQueueAutoscalerType = "tidal"
33+
VerticalQueueAutoscalerMetricsType VerticalQueueAutoscalerType = "metrics"
34+
EquivalentStepType StepType = "equivalent"
35+
EquiratioStepType StepType = "equiratio"
36+
AndCondition Condition = "and"
37+
OrCondition Condition = "or"
38+
)
39+
40+
// +genclient
41+
// +genclient:nonNamespaced
42+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
43+
// +kubebuilder:object:root=true
44+
// +kubebuilder:resource:path=verticalqueueautoscalers,shortName=vqa;vqas,scope=Cluster
45+
// +kubebuilder:subresource:status
46+
// +kubebuilder:printcolumn:name="Last Scale",type=date,JSONPath=`.status.lastScaleTime`
47+
// +kubebuilder:printcolumn:name="Last Successful",type=date,JSONPath=`.status.lastScaleSuccessTime`
48+
// +kubebuilder:printcolumn:name="AGE",type=date,JSONPath=`.metadata.creationTimestamp`
49+
// +kubebuilder:printcolumn:name="QUEUE",type=string,priority=1,JSONPath=`.spec.queue`
50+
51+
// VerticalQueueAutoscaler defines the volcano vertical queue autoscaler.
52+
type VerticalQueueAutoscaler struct {
53+
metav1.TypeMeta `json:",inline"`
54+
55+
// +optional
56+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
57+
58+
// Specification of the desired behavior of the volcano verticalqueueautoscaler, including tidal and metrics
59+
// +optional
60+
Spec VQASpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
61+
62+
// Current status of the volcano verticalqueueautoscaler
63+
// +optional
64+
Status VQAStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
65+
}
66+
67+
// VQASpec describes how the VerticalQueueAutoscaler will look like and actually behavior.
68+
type VQASpec struct {
69+
70+
//Specifies the queue that will be used in the scheduler, "default" queue is used this leaves empty.
71+
Queue string `json:"queue,omitempty" protobuf:"bytes,1,opt,name=queue"`
72+
73+
// Type is the behavior type of VQA.
74+
//+kubebuilder:validation:Enum=tidal;metrics
75+
Type VerticalQueueAutoscalerType `json:"type,omitempty" protobuf:"bytes,2,opt,name=type"`
76+
77+
// TidalSpec define tidal autoscaling configuration
78+
// +optional
79+
TidalSpec TidalSpec `json:"tidalSpec,omitempty" protobuf:"bytes,3,opt,name=tidalSpec"`
80+
81+
// TidalSpec define metrics autoscaling configuration
82+
// +optional
83+
MetricSpec []MetricSpec `json:"metricSpec,omitempty" protobuf:"bytes,4,opt,name=metricSpec"`
84+
}
85+
86+
type VQAStatus struct {
87+
// LastScaleTime is the last time the VerticalQueueAutoscaler scaled the capacity of queue,
88+
// +optional
89+
LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty" protobuf:"bytes,1,opt,name=lastScaleTime"`
90+
91+
// LastScaleSuccessTime is the last time the VerticalQueueAutoscaler scaled the capacity of queue Successful,
92+
// +optional
93+
LastScaleSuccessTime *metav1.Time `json:"lastScaleSuccessTime,omitempty" protobuf:"bytes,2,opt,name=lastScaleSuccessTime"`
94+
}
95+
96+
type TidalSpec struct {
97+
// StartingDeadlineSeconds Optional deadline in seconds for starting the job if it misses scheduled
98+
// time for any reason. Missed jobs executions will be counted as failed ones.
99+
// +optional
100+
StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty" protobuf:"varint,1,opt,name=startingDeadlineSeconds"`
101+
102+
// Tidal define arrays of tidal configuration
103+
Tidal []Tidal `json:"tidal,omitempty" protobuf:"bytes,2,opt,name=tidal"`
104+
}
105+
106+
type Tidal struct {
107+
// Schedule The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron
108+
Schedule string `json:"schedule,omitempty" protobuf:"bytes,1,opt,name=schedule"`
109+
// Weight queue.spec.weight
110+
Weight int32 `json:"weight,omitempty" protobuf:"bytes,2,opt,name=weight"`
111+
// Capability queue.spec.capability
112+
Capability corev1.ResourceList `json:"capability,omitempty" protobuf:"bytes,3,opt,name=capability"`
113+
// Guarantee queue.spec.guarantee.resource
114+
Guarantee corev1.ResourceList `json:"guarantee,omitempty" protobuf:"bytes,4,opt,name=guarantee"`
115+
}
116+
117+
type MetricSpec struct {
118+
// ScaleBehavior define scale behavior of metrics type
119+
ScaleBehavior ScaleBehavior `json:"scaleBehavior,omitempty" protobuf:"bytes,1,opt,name=scaleBehavior"`
120+
// ResourceLimit resources limit of queue
121+
ResourceLimit ResourceLimit `json:"resourceLimit,omitempty" protobuf:"bytes,2,opt,name=resourceLimit"`
122+
MetricRules MetricRules `json:"metricRules,omitempty" protobuf:"bytes,3,opt,name=metricRules"`
123+
}
124+
125+
type ScaleBehavior struct {
126+
// StepType scale step type
127+
//+kubebuilder:validation:Enum=Delete;Orphan
128+
StepType StepType `json:"stepType,omitempty" protobuf:"bytes,1,opt,name=stepType"`
129+
// StepRatio ratio of scale step
130+
StepRatio resource.Quantity `json:"stepRatio,omitempty" protobuf:"bytes,2,opt,name=stepRatio"`
131+
// StepResources resources of scale step
132+
StepResources StepResources `json:"stepResources,omitempty" protobuf:"bytes,3,opt,name=stepResources"`
133+
}
134+
135+
type StepResources struct {
136+
// Weight queue.spec.weight, it's a increment
137+
Weight int32 `json:"weight,omitempty" protobuf:"bytes,1,opt,name=weight"`
138+
// Capability queue.spec.capability, it's a increment
139+
Capability corev1.ResourceList `json:"capability,omitempty" protobuf:"bytes,2,opt,name=capability"`
140+
// Guarantee queue.spec.guarantee.resource, it's a increment
141+
Guarantee corev1.ResourceList `json:"guarantee,omitempty" protobuf:"bytes,3,opt,name=guarantee"`
142+
}
143+
144+
type ScaleLimit struct {
145+
// WeightLimit limit of queue.spec.weight
146+
WeightLimit WeightLimit `json:"weightLimit,omitempty" protobuf:"bytes,1,opt,name=weightLimit"`
147+
// CapacityLimit limit of queue.spec.capability
148+
CapacityLimit ResourceLimit `json:"capacityLimit,omitempty" protobuf:"bytes,2,opt,name=capacityLimit"`
149+
// GuaranteeLimit limit of queue.spec.guarantee.resource
150+
GuaranteeLimit ResourceLimit `json:"guaratneeLimit,omitempty" protobuf:"bytes,3,opt,name=guaratneeLimit"`
151+
}
152+
153+
type WeightLimit struct {
154+
// Min minimum of queue.spec.weight
155+
Min int32 `json:"min,omitempty" protobuf:"bytes,1,opt,name=min"`
156+
// Max maximum of queue.spec.weight
157+
Max int32 `json:"max,omitempty" protobuf:"bytes,2,opt,name=max"`
158+
}
159+
160+
type ResourceLimit struct {
161+
// Min minimum of queue.spec.capacity or guarantee
162+
Min corev1.ResourceList `json:"min,omitempty" protobuf:"bytes,1,opt,name=min"`
163+
// Max maximum of queue.spec.capacity or guarantee
164+
Max corev1.ResourceList `json:"max,omitempty" protobuf:"bytes,2,opt,name=max"`
165+
}
166+
167+
type MetricRules struct {
168+
// ScaleUp rule of scale up
169+
ScaleUp ScaleRule `json:"scaleUp,omitempty" protobuf:"bytes,1,opt,name=scaleUp"`
170+
// ScaleUp rule of scale down
171+
ScaleDown ScaleRule `json:"scaleDown,omitempty" protobuf:"bytes,2,opt,name=scaleDown"`
172+
}
173+
174+
type ScaleRule struct {
175+
// StabilizationWindowSeconds is the number of seconds for which past recommendations should be
176+
// considered while scaling up or scaling down.
177+
// StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour).
178+
// If not set, use the default values:
179+
// - For scale up: 0 (i.e. no stabilization is done).
180+
// - For scale down: 300 (i.e. the stabilization window is 300 seconds long).
181+
// +optional
182+
StabilizationWindowSeconds *int32 `json:"stabilizationWindowSeconds,omitempty" protobuf:"bytes,1,opt,name=stabilizationWindowSeconds"`
183+
Condition Condition `json:"condition,omitempty" protobuf:"bytes,2,opt,name=condition"`
184+
MetricSources []MetricSource `json:"metricSources,omitempty" protobuf:"bytes,3,opt,name=metricSources"`
185+
}
186+
187+
type MetricSource struct {
188+
// PeriodSeconds specifies the window of time for which the policy should hold true.
189+
// PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min).
190+
PeriodSeconds int32 `json:"periodSeconds"`
191+
// Metric identifies the target metric by name and selector
192+
Metric v2.MetricIdentifier `json:"metric,omitempty"`
193+
// Target specifies the target value for the given metric
194+
Target v2.MetricTarget `json:"target,omitempty"`
195+
}
196+
197+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
198+
199+
// VerticalQueueAutoscalerList is a collection of vertical queue autoscaler.
200+
type VerticalQueueAutoscalerList struct {
201+
metav1.TypeMeta
202+
// Standard list metadata
203+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
204+
// +optional
205+
metav1.ListMeta
206+
207+
// items is the list of VerticalQueueAutoscaler
208+
Items []VerticalQueueAutoscaler
209+
}

0 commit comments

Comments
 (0)