Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Please note this table only reports end-to-end tests suite coverage, others vers
- [x] Cluster monitoring.
- [x] Complete end2end test suite.
- [x] Archival.
- [ ] Auto scaling.
- [x] Auto scaling.
- [ ] Multi cluster replication.

## Contributing
Expand Down
36 changes: 36 additions & 0 deletions api/v1beta1/temporalcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"go.temporal.io/server/common/primitives"
"golang.org/x/exp/slices"
autoscalingv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -62,6 +63,32 @@ type LogSpec struct {
Development bool `json:"development"`
}

// AutoscalingSpec defines the configuration for Horizontal Pod Autoscaling.
type AutoscalingSpec struct {
// MinReplicas is the lower limit for the number of replicas to which the autoscaler
// can scale down. It defaults to 1 pod.
// +optional
// +kubebuilder:validation:Minimum=1
MinReplicas *int32 `json:"minReplicas,omitempty"`

// MaxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up.
// +kubebuilder:validation:Minimum=1
// +optional
MaxReplicas *int32 `json:"maxReplicas,omitempty"`

// Metrics contains the specifications for which to use to calculate the
// desired replica count (the maximum replica count across all metrics will
// be used). If not set, defaults to 80% CPU and 70% memory utilization.
// +optional
Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty"`

// Behavior configures the scaling behavior of the target
// in both Up and Down directions (scaleUp and scaleDown fields respectively).
// If not set, the default HPAScalingRules for scale up and scale down are used.
// +optional
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
}

// ServiceSpec contains a temporal service specifications.
type ServiceSpec struct {
// Port defines a custom gRPC port for the service.
Expand Down Expand Up @@ -100,6 +127,10 @@ type ServiceSpec struct {
// InitContainers adds a list of init containers to the service's deployment.
// +optional
InitContainers []corev1.Container `json:"initContainers,omitempty"`
// Autoscaling enables horizontal pod autoscaling for the service.
// When enabled, the controller will bypass the replicas field and create an HPA resource instead.
// +optional
Autoscaling *AutoscalingSpec `json:"autoscaling,omitempty"`
// ServiceAccountOverride
}

Expand All @@ -116,6 +147,11 @@ func (s *InternalFrontendServiceSpec) IsEnabled() bool {
return s != nil && s.Enabled
}

// IsAutoscalingEnabled returns true if autoscaling is enabled for the service.
func (s *ServiceSpec) IsAutoscalingEnabled() bool {
return s != nil && s.Autoscaling != nil
}

// ServicesSpec contains all temporal services specifications.
type ServicesSpec struct {
// Frontend service custom specifications.
Expand Down
43 changes: 43 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

Loading