Skip to content

Commit

Permalink
Add support for initialCooldownPeriod On httpScaledObjects
Browse files Browse the repository at this point in the history
Signed-off-by: Shay Rybak <[email protected]>
  • Loading branch information
shayrybak committed Dec 11, 2024
1 parent 45f645f commit b929705
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions operator/apis/http/v1alpha1/httpscaledobject_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type HTTPScaledObjectSpec struct {
// (optional) Cooldown period value
// +optional
CooldownPeriod *int32 `json:"scaledownPeriod,omitempty" description:"Cooldown period (seconds) for resources to scale down (Default 300)"`
// (optional) Initial period before scaling
// +optional
InitialCooldownPeriod int32 `json:"initialCooldownPeriod,omitempty" description:"Initial period (seconds) before scaling (Default 0)"`
// (optional) Configuration for the metric used for scaling
// +optional
ScalingMetric *ScalingMetricSpec `json:"scalingMetric,omitempty" description:"Configuration for the metric used for scaling. If empty 'concurrency' will be used"`
Expand Down
1 change: 1 addition & 0 deletions operator/controllers/http/scaled_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (r *HTTPScaledObjectReconciler) createOrUpdateScaledObject(
minReplicaCount,
maxReplicaCount,
httpso.Spec.CooldownPeriod,
httpso.Spec.InitialCooldownPeriod,
)

// Set HTTPScaledObject instance as the owner and controller
Expand Down
10 changes: 6 additions & 4 deletions pkg/k8s/scaledobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewScaledObject(
minReplicas *int32,
maxReplicas *int32,
cooldownPeriod *int32,
initialCooldownPeriod int32,
) *kedav1alpha1.ScaledObject {
return &kedav1alpha1.ScaledObject{
TypeMeta: metav1.TypeMeta{
Expand All @@ -45,10 +46,11 @@ func NewScaledObject(
Kind: workloadRef.Kind,
Name: workloadRef.Name,
},
PollingInterval: ptr.To[int32](soPollingInterval),
CooldownPeriod: cooldownPeriod,
MinReplicaCount: minReplicas,
MaxReplicaCount: maxReplicas,
PollingInterval: ptr.To[int32](soPollingInterval),
CooldownPeriod: cooldownPeriod,
InitialCooldownPeriod: initialCooldownPeriod,
MinReplicaCount: minReplicas,
MaxReplicaCount: maxReplicas,
Advanced: &kedav1alpha1.AdvancedConfig{
RestoreToOriginalReplicaCount: true,
},
Expand Down

0 comments on commit b929705

Please sign in to comment.