Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for autoscaling/v2 #547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions api/v1/runtimecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
routev1 "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
autoscalingv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -225,6 +226,16 @@ type RuntimeComponentAutoScaling struct {
// Target average CPU utilization, represented as a percentage of requested CPU, over all the pods.
// +operator-sdk:csv:customresourcedefinitions:order=3,type=spec,displayName="Target CPU Utilization Percentage",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number"
TargetCPUUtilizationPercentage *int32 `json:"targetCPUUtilizationPercentage,omitempty"`

// Target average Memory utilization, represented as a percentage of requested memory, over all the pods.
// +operator-sdk:csv:customresourcedefinitions:order=4,type=spec,displayName="Target Memory Utilization Percentage",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number"
TargetMemoryUtilizationPercentage *int32 `json:"targetMemoryUtilizationPercentage,omitempty"`

// Specifications used for replica count calculation
Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty"`

// Scaling behavior of the target. If not set, the default HPAScalingRules for scale up and scale down are used.
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
}

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

// GetTargetMemoryUtilizationPercentage returns target memory usage
func (a *RuntimeComponentAutoScaling) GetTargetMemoryUtilizationPercentage() *int32 {
return a.TargetMemoryUtilizationPercentage
}

// GetMetrics returns metrics for resource utilization
func (a *RuntimeComponentAutoScaling) GetMetrics() []autoscalingv2.MetricSpec {
return a.Metrics
}

// GetHorizontalPodAutoscalerBehavior returns behavior configures the scaling behavior of the target
func (a *RuntimeComponentAutoScaling) GetHorizontalPodAutoscalerBehavior() *autoscalingv2.HorizontalPodAutoscalerBehavior {
return a.Behavior
}

// GetSize returns persistent volume size
func (s *RuntimeComponentStorage) GetSize() string {
return s.Size
Expand Down
18 changes: 18 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions api/v1beta2/runtimecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
routev1 "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
autoscalingv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -666,6 +667,21 @@ func (a *RuntimeComponentAutoScaling) GetTargetCPUUtilizationPercentage() *int32
return a.TargetCPUUtilizationPercentage
}

// GetTargetMemoryUtilizationPercentage returns target memory usage
func (a *RuntimeComponentAutoScaling) GetTargetMemoryUtilizationPercentage() *int32 {
return nil
}

// GetMetrics returns metrics for resource utilization
func (a *RuntimeComponentAutoScaling) GetMetrics() []autoscalingv2.MetricSpec {
return nil
}

// GetHorizontalPodAutoscalerBehavior returns behavior configures the scaling behavior of the target
func (a *RuntimeComponentAutoScaling) GetHorizontalPodAutoscalerBehavior() *autoscalingv2.HorizontalPodAutoscalerBehavior {
return nil
}

// GetSize returns persistent volume size
func (s *RuntimeComponentStorage) GetSize() string {
return s.Size
Expand Down
Loading