wmedvede opened a new issue, #3432:
URL: https://github.com/apache/incubator-kie-tools/issues/3432
We must provide the ablitly for users to define `HorizonalPodAutoscalers` to
manage workflows and Data Index replicas respectivelly.
Users wants to:
Given a workflow `my-workflow`, create an `HorizontalPodAutoscaler` like the
example below, that targets the given workflow, and the associated `Deployment`
replicas must be automaticaly managed the `HorizontalPodAutoscaler`. When, no
`HorizontalPodAutoscaler` is defined, the workflow replicas must be managed by
the `SonataFlow` controller as it does now.
```
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-workflow-hpa
spec:
scaleTargetRef:
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
name: my-workflow
minReplicas: 4
maxReplicas: 8
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
```
**Solution for SonataFlow workflows:**
The `SonataFlow CRD` will implement the `/scale` subresoruce API, by addign
the makers below to the `SonataFlow` type, and the corresponding fields to the
`Status`. Giving that defintion, a workflow can be now configured as the
`HorizontalPodAutoscaler` `scaleTargetRef`. At runtime, when such
`HorizonalPodAutoscaler` is created, the given controller will manage to scale
the workflow replicas. The `SonataFlow` controller will smartly manage that
situation in the following way:
1) If an `HorizonalPodAutoscaller` is defined, the `Deployment`replicas will
be managed by that controller. And, the `SonataFlow` controller will configure
the `Deployment` with the replicas provided by that controller.
2) When no `HorizonalPodAutoscaller` is defined, the `SonataFlow` controller
will manage the replicas as usual.
Note: since the `SontaFlow` will implement the `/scale`, the
`HorizonalPodAutoscaller` controller will interact directly with it. The
`SonataFlow controller` will manage this situation internally.
`//
+kubebuilder:subresource:scale:specpath=.spec.podTemplate.replicas,statuspath=.status.replicas,selectorpath=.status.selector
`
```
// Replicas is the actual number of observed queryable pods.
// This is required by the HPA via the scale subresource.
// +optional
Replicas int32 `json:"replicas,omitempty"`
// Selector is the queryable label selector for pods, in string format.
// HPA uses this to find the pods and collect metrics (CPU/Memory).
// +optional
Selector string `json:"selector,omitempty"`
```
**Solution for Data Index deployments:**
The `SonataFlowPlatform` controller will be augmented to detect a potential
`HorizonalPodAutoscaller` that targets the current Data Index `Deployment` in a
given namespace. If such `HorizonalPodAutoscaller` exists, the
`SonataFlowPlatorm` controller will let the replicas managment to the external
controller, in other cases, it'll mange the replicas as usual.
Note: In this case, when present, the `HorizontalPodAutoscaller` will target
and manage the given `Deployment` directly.
```
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: sonataflow-platform-data-index-service-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: sonataflow-platform-data-index-service
minReplicas: 3
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]