diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go
index ac79522da0..862d91f6db 100644
--- a/apis/v1alpha1/opentelemetrycollector_types.go
+++ b/apis/v1alpha1/opentelemetrycollector_types.go
@@ -15,6 +15,7 @@
package v1alpha1
import (
+ autoscalingv2 "k8s.io/api/autoscaling/v2"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -40,6 +41,13 @@ type OpenTelemetryCollectorSpec struct {
// MaxReplicas sets an upper bound to the autoscaling feature. If MaxReplicas is set autoscaling is enabled.
// +optional
MaxReplicas *int32 `json:"maxReplicas,omitempty"`
+
+ // Autoscaler specifies the pod autoscaling configuration to use
+ // for the OpenTelemetryCollector workload.
+ //
+ // +optional
+ Autoscaler *AutoscalerSpec `json:"autoscaler,omitempty"`
+
// SecurityContext will be set as the container security context.
// +optional
SecurityContext *v1.SecurityContext `json:"securityContext,omitempty"`
@@ -197,6 +205,12 @@ type OpenTelemetryCollectorList struct {
Items []OpenTelemetryCollector `json:"items"`
}
+// AutoscalerSpec defines the OpenTelemetryCollector's pod autoscaling specification.
+type AutoscalerSpec struct {
+ // +optional
+ Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
+}
+
func init() {
SchemeBuilder.Register(&OpenTelemetryCollector{}, &OpenTelemetryCollectorList{})
}
diff --git a/apis/v1alpha1/opentelemetrycollector_webhook.go b/apis/v1alpha1/opentelemetrycollector_webhook.go
index 6a4b1e936f..b8df65c956 100644
--- a/apis/v1alpha1/opentelemetrycollector_webhook.go
+++ b/apis/v1alpha1/opentelemetrycollector_webhook.go
@@ -129,6 +129,15 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error {
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas should be one or more")
}
+ if r.Spec.Autoscaler != nil && r.Spec.Autoscaler.Behavior != nil {
+ if r.Spec.Autoscaler.Behavior.ScaleDown != nil && *r.Spec.Autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds < int32(1) {
+ return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, scaleDown should be one or more")
+ }
+
+ if r.Spec.Autoscaler.Behavior.ScaleUp != nil && *r.Spec.Autoscaler.Behavior.ScaleUp.StabilizationWindowSeconds < int32(1) {
+ return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, scaleUp should be one or more")
+ }
+ }
}
return nil
diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go
index 776bebf9fd..0f81becc74 100644
--- a/apis/v1alpha1/zz_generated.deepcopy.go
+++ b/apis/v1alpha1/zz_generated.deepcopy.go
@@ -20,10 +20,31 @@
package v1alpha1
import (
- v1 "k8s.io/api/core/v1"
+ "k8s.io/api/autoscaling/v2"
+ "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *AutoscalerSpec) DeepCopyInto(out *AutoscalerSpec) {
+ *out = *in
+ if in.Behavior != nil {
+ in, out := &in.Behavior, &out.Behavior
+ *out = new(v2.HorizontalPodAutoscalerBehavior)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalerSpec.
+func (in *AutoscalerSpec) DeepCopy() *AutoscalerSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(AutoscalerSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DotNet) DeepCopyInto(out *DotNet) {
*out = *in
@@ -305,6 +326,11 @@ func (in *OpenTelemetryCollectorSpec) DeepCopyInto(out *OpenTelemetryCollectorSp
*out = new(int32)
**out = **in
}
+ if in.Autoscaler != nil {
+ in, out := &in.Autoscaler, &out.Autoscaler
+ *out = new(AutoscalerSpec)
+ (*in).DeepCopyInto(*out)
+ }
if in.SecurityContext != nil {
in, out := &in.SecurityContext, &out.SecurityContext
*out = new(v1.SecurityContext)
diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
index 01dc8f2e2b..d7f09b06a0 100644
--- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
@@ -59,6 +59,130 @@ spec:
description: Args is the set of arguments to pass to the OpenTelemetry
Collector binary
type: object
+ autoscaler:
+ description: Autoscaler specifies the pod autoscaling configuration
+ to use for the OpenTelemetryCollector workload.
+ properties:
+ behavior:
+ description: HorizontalPodAutoscalerBehavior configures the scaling
+ behavior of the target in both Up and Down directions (scaleUp
+ and scaleDown fields respectively).
+ properties:
+ scaleDown:
+ description: scaleDown is scaling policy for scaling Down.
+ If not set, the default value is to allow to scale down
+ to minReplicas pods, with a 300 second stabilization window
+ (i.e., the highest recommendation for the last 300sec is
+ used).
+ properties:
+ policies:
+ description: policies is a list of potential scaling polices
+ which can be used during scaling. At least one policy
+ must be specified, otherwise the HPAScalingRules will
+ be discarded as invalid
+ items:
+ description: HPAScalingPolicy is a single policy which
+ must hold true for a specified past interval.
+ properties:
+ periodSeconds:
+ description: PeriodSeconds specifies the window
+ of time for which the policy should hold true.
+ PeriodSeconds must be greater than zero and less
+ than or equal to 1800 (30 min).
+ format: int32
+ type: integer
+ type:
+ description: Type is used to specify the scaling
+ policy.
+ type: string
+ value:
+ description: Value contains the amount of change
+ which is permitted by the policy. It must be greater
+ than zero
+ format: int32
+ type: integer
+ required:
+ - periodSeconds
+ - type
+ - value
+ type: object
+ type: array
+ x-kubernetes-list-type: atomic
+ selectPolicy:
+ description: selectPolicy is used to specify which policy
+ should be used. If not set, the default value Max is
+ used.
+ type: string
+ stabilizationWindowSeconds:
+ description: 'StabilizationWindowSeconds is the number
+ of seconds for which past recommendations should be
+ considered while scaling up or scaling down. StabilizationWindowSeconds
+ must be greater than or equal to zero and less than
+ or equal to 3600 (one hour). If not set, use the default
+ values: - For scale up: 0 (i.e. no stabilization is
+ done). - For scale down: 300 (i.e. the stabilization
+ window is 300 seconds long).'
+ format: int32
+ type: integer
+ type: object
+ scaleUp:
+ description: 'scaleUp is scaling policy for scaling Up. If
+ not set, the default value is the higher of: * increase
+ no more than 4 pods per 60 seconds * double the number of
+ pods per 60 seconds No stabilization is used.'
+ properties:
+ policies:
+ description: policies is a list of potential scaling polices
+ which can be used during scaling. At least one policy
+ must be specified, otherwise the HPAScalingRules will
+ be discarded as invalid
+ items:
+ description: HPAScalingPolicy is a single policy which
+ must hold true for a specified past interval.
+ properties:
+ periodSeconds:
+ description: PeriodSeconds specifies the window
+ of time for which the policy should hold true.
+ PeriodSeconds must be greater than zero and less
+ than or equal to 1800 (30 min).
+ format: int32
+ type: integer
+ type:
+ description: Type is used to specify the scaling
+ policy.
+ type: string
+ value:
+ description: Value contains the amount of change
+ which is permitted by the policy. It must be greater
+ than zero
+ format: int32
+ type: integer
+ required:
+ - periodSeconds
+ - type
+ - value
+ type: object
+ type: array
+ x-kubernetes-list-type: atomic
+ selectPolicy:
+ description: selectPolicy is used to specify which policy
+ should be used. If not set, the default value Max is
+ used.
+ type: string
+ stabilizationWindowSeconds:
+ description: 'StabilizationWindowSeconds is the number
+ of seconds for which past recommendations should be
+ considered while scaling up or scaling down. StabilizationWindowSeconds
+ must be greater than or equal to zero and less than
+ or equal to 3600 (one hour). If not set, use the default
+ values: - For scale up: 0 (i.e. no stabilization is
+ done). - For scale down: 300 (i.e. the stabilization
+ window is 300 seconds long).'
+ format: int32
+ type: integer
+ type: object
+ type: object
+ type: object
config:
description: Config is the raw JSON to be used as the collector's
configuration. Refer to the OpenTelemetry Collector documentation
diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
index b2f0bf3d0c..88e8f28cfd 100644
--- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
@@ -57,6 +57,130 @@ spec:
description: Args is the set of arguments to pass to the OpenTelemetry
Collector binary
type: object
+ autoscaler:
+ description: Autoscaler specifies the pod autoscaling configuration
+ to use for the OpenTelemetryCollector workload.
+ properties:
+ behavior:
+ description: HorizontalPodAutoscalerBehavior configures the scaling
+ behavior of the target in both Up and Down directions (scaleUp
+ and scaleDown fields respectively).
+ properties:
+ scaleDown:
+ description: scaleDown is scaling policy for scaling Down.
+ If not set, the default value is to allow to scale down
+ to minReplicas pods, with a 300 second stabilization window
+ (i.e., the highest recommendation for the last 300sec is
+ used).
+ properties:
+ policies:
+ description: policies is a list of potential scaling polices
+ which can be used during scaling. At least one policy
+ must be specified, otherwise the HPAScalingRules will
+ be discarded as invalid
+ items:
+ description: HPAScalingPolicy is a single policy which
+ must hold true for a specified past interval.
+ properties:
+ periodSeconds:
+ description: PeriodSeconds specifies the window
+ of time for which the policy should hold true.
+ PeriodSeconds must be greater than zero and less
+ than or equal to 1800 (30 min).
+ format: int32
+ type: integer
+ type:
+ description: Type is used to specify the scaling
+ policy.
+ type: string
+ value:
+ description: Value contains the amount of change
+ which is permitted by the policy. It must be greater
+ than zero
+ format: int32
+ type: integer
+ required:
+ - periodSeconds
+ - type
+ - value
+ type: object
+ type: array
+ x-kubernetes-list-type: atomic
+ selectPolicy:
+ description: selectPolicy is used to specify which policy
+ should be used. If not set, the default value Max is
+ used.
+ type: string
+ stabilizationWindowSeconds:
+ description: 'StabilizationWindowSeconds is the number
+ of seconds for which past recommendations should be
+ considered while scaling up or scaling down. StabilizationWindowSeconds
+ must be greater than or equal to zero and less than
+ or equal to 3600 (one hour). If not set, use the default
+ values: - For scale up: 0 (i.e. no stabilization is
+ done). - For scale down: 300 (i.e. the stabilization
+ window is 300 seconds long).'
+ format: int32
+ type: integer
+ type: object
+ scaleUp:
+ description: 'scaleUp is scaling policy for scaling Up. If
+ not set, the default value is the higher of: * increase
+ no more than 4 pods per 60 seconds * double the number of
+ pods per 60 seconds No stabilization is used.'
+ properties:
+ policies:
+ description: policies is a list of potential scaling polices
+ which can be used during scaling. At least one policy
+ must be specified, otherwise the HPAScalingRules will
+ be discarded as invalid
+ items:
+ description: HPAScalingPolicy is a single policy which
+ must hold true for a specified past interval.
+ properties:
+ periodSeconds:
+ description: PeriodSeconds specifies the window
+ of time for which the policy should hold true.
+ PeriodSeconds must be greater than zero and less
+ than or equal to 1800 (30 min).
+ format: int32
+ type: integer
+ type:
+ description: Type is used to specify the scaling
+ policy.
+ type: string
+ value:
+ description: Value contains the amount of change
+ which is permitted by the policy. It must be greater
+ than zero
+ format: int32
+ type: integer
+ required:
+ - periodSeconds
+ - type
+ - value
+ type: object
+ type: array
+ x-kubernetes-list-type: atomic
+ selectPolicy:
+ description: selectPolicy is used to specify which policy
+ should be used. If not set, the default value Max is
+ used.
+ type: string
+ stabilizationWindowSeconds:
+ description: 'StabilizationWindowSeconds is the number
+ of seconds for which past recommendations should be
+ considered while scaling up or scaling down. StabilizationWindowSeconds
+ must be greater than or equal to zero and less than
+ or equal to 3600 (one hour). If not set, use the default
+ values: - For scale up: 0 (i.e. no stabilization is
+ done). - For scale down: 300 (i.e. the stabilization
+ window is 300 seconds long).'
+ format: int32
+ type: integer
+ type: object
+ type: object
+ type: object
config:
description: Config is the raw JSON to be used as the collector's
configuration. Refer to the OpenTelemetry Collector documentation
diff --git a/docs/api.md b/docs/api.md
index 6dcb8b56ec..97c0fba762 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -1691,6 +1691,13 @@ OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector.
Args is the set of arguments to pass to the OpenTelemetry Collector binary
Name | +Type | +Description | +Required | +
---|---|---|---|
behavior | +object | +
+ HorizontalPodAutoscalerBehavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). + |
+ false | +
Name | +Type | +Description | +Required | +
---|---|---|---|
scaleDown | +object | +
+ scaleDown is scaling policy for scaling Down. If not set, the default value is to allow to scale down to minReplicas pods, with a 300 second stabilization window (i.e., the highest recommendation for the last 300sec is used). + |
+ false | +
scaleUp | +object | +
+ scaleUp is scaling policy for scaling Up. If not set, the default value is the higher of: * increase no more than 4 pods per 60 seconds * double the number of pods per 60 seconds No stabilization is used. + |
+ false | +
Name | +Type | +Description | +Required | +
---|---|---|---|
policies | +[]object | +
+ policies is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid + |
+ false | +
selectPolicy | +string | +
+ selectPolicy is used to specify which policy should be used. If not set, the default value Max is used. + |
+ false | +
stabilizationWindowSeconds | +integer | +
+ StabilizationWindowSeconds is the number of seconds for which past recommendations should be considered while scaling up or scaling down. StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). If not set, use the default values: - For scale up: 0 (i.e. no stabilization is done). - For scale down: 300 (i.e. the stabilization window is 300 seconds long). + + Format: int32 + |
+ false | +
Name | +Type | +Description | +Required | +
---|---|---|---|
periodSeconds | +integer | +
+ PeriodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + + Format: int32 + |
+ true | +
type | +string | +
+ Type is used to specify the scaling policy. + |
+ true | +
value | +integer | +
+ Value contains the amount of change which is permitted by the policy. It must be greater than zero + + Format: int32 + |
+ true | +
Name | +Type | +Description | +Required | +
---|---|---|---|
policies | +[]object | +
+ policies is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid + |
+ false | +
selectPolicy | +string | +
+ selectPolicy is used to specify which policy should be used. If not set, the default value Max is used. + |
+ false | +
stabilizationWindowSeconds | +integer | +
+ StabilizationWindowSeconds is the number of seconds for which past recommendations should be considered while scaling up or scaling down. StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). If not set, use the default values: - For scale up: 0 (i.e. no stabilization is done). - For scale down: 300 (i.e. the stabilization window is 300 seconds long). + + Format: int32 + |
+ false | +
Name | +Type | +Description | +Required | +
---|---|---|---|
periodSeconds | +integer | +
+ PeriodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + + Format: int32 + |
+ true | +
type | +string | +
+ Type is used to specify the scaling policy. + |
+ true | +
value | +integer | +
+ Value contains the amount of change which is permitted by the policy. It must be greater than zero + + Format: int32 + |
+ true | +