Skip to content

Commit a3c6975

Browse files
committed
Add support for autoscaling/v2
1 parent 4f58550 commit a3c6975

18 files changed

+2678
-50
lines changed

api/v1/runtimecomponent_types.go

+26
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
routev1 "github.com/openshift/api/route/v1"
2424
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
2525
appsv1 "k8s.io/api/apps/v1"
26+
autoscalingv2 "k8s.io/api/autoscaling/v2"
2627
corev1 "k8s.io/api/core/v1"
2728
networkingv1 "k8s.io/api/networking/v1"
2829
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -225,6 +226,16 @@ type RuntimeComponentAutoScaling struct {
225226
// Target average CPU utilization, represented as a percentage of requested CPU, over all the pods.
226227
// +operator-sdk:csv:customresourcedefinitions:order=3,type=spec,displayName="Target CPU Utilization Percentage",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number"
227228
TargetCPUUtilizationPercentage *int32 `json:"targetCPUUtilizationPercentage,omitempty"`
229+
230+
// Target average Memory utilization, represented as a percentage of requested memory, over all the pods.
231+
// +operator-sdk:csv:customresourcedefinitions:order=4,type=spec,displayName="Target Memory Utilization Percentage",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number"
232+
TargetMemoryUtilizationPercentage *int32 `json:"targetMemoryUtilizationPercentage,omitempty"`
233+
234+
// Specifications used for replica count calculation
235+
Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty"`
236+
237+
// Scaling behavior of the target. If not set, the default HPAScalingRules for scale up and scale down are used.
238+
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
228239
}
229240

230241
// Configures parameters for the network service of pods.
@@ -762,6 +773,21 @@ func (a *RuntimeComponentAutoScaling) GetTargetCPUUtilizationPercentage() *int32
762773
return a.TargetCPUUtilizationPercentage
763774
}
764775

776+
// GetTargetMemoryUtilizationPercentage returns target memory usage
777+
func (a *RuntimeComponentAutoScaling) GetTargetMemoryUtilizationPercentage() *int32 {
778+
return a.TargetMemoryUtilizationPercentage
779+
}
780+
781+
// GetMetrics returns metrics for resource utilization
782+
func (a *RuntimeComponentAutoScaling) GetMetrics() []autoscalingv2.MetricSpec {
783+
return a.Metrics
784+
}
785+
786+
// GetHorizontalPodAutoscalerBehavior returns behavior configures the scaling behavior of the target
787+
func (a *RuntimeComponentAutoScaling) GetHorizontalPodAutoscalerBehavior() *autoscalingv2.HorizontalPodAutoscalerBehavior {
788+
return a.Behavior
789+
}
790+
765791
// GetSize returns persistent volume size
766792
func (s *RuntimeComponentStorage) GetSize() string {
767793
return s.Size

api/v1/zz_generated.deepcopy.go

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/runtimecomponent_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
routev1 "github.com/openshift/api/route/v1"
2424
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
2525
appsv1 "k8s.io/api/apps/v1"
26+
autoscalingv2 "k8s.io/api/autoscaling/v2"
2627
corev1 "k8s.io/api/core/v1"
2728
networkingv1 "k8s.io/api/networking/v1"
2829
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -666,6 +667,21 @@ func (a *RuntimeComponentAutoScaling) GetTargetCPUUtilizationPercentage() *int32
666667
return a.TargetCPUUtilizationPercentage
667668
}
668669

670+
// GetTargetMemoryUtilizationPercentage returns target memory usage
671+
func (a *RuntimeComponentAutoScaling) GetTargetMemoryUtilizationPercentage() *int32 {
672+
return nil
673+
}
674+
675+
// GetMetrics returns metrics for resource utilization
676+
func (a *RuntimeComponentAutoScaling) GetMetrics() []autoscalingv2.MetricSpec {
677+
return nil
678+
}
679+
680+
// GetHorizontalPodAutoscalerBehavior returns behavior configures the scaling behavior of the target
681+
func (a *RuntimeComponentAutoScaling) GetHorizontalPodAutoscalerBehavior() *autoscalingv2.HorizontalPodAutoscalerBehavior {
682+
return nil
683+
}
684+
669685
// GetSize returns persistent volume size
670686
func (s *RuntimeComponentStorage) GetSize() string {
671687
return s.Size

0 commit comments

Comments
 (0)