The cpuscaler trait provides a mechanism to dynamically change the number of replicas of a given component based on the CPU utilization. This is useful for components that exhibit timely patterns in their workloads (e.g., processing pipelines, user-facing components, etc.).
The following snippet contains an example to dynamically scale a component between 1 and 3 replicas depending on the CPU utilization of the replicas and a given threshold.
apiVersion: core.oam.dev/v1beta1 kind: Application metadata: name: my-app annotations: version: "v0.0.1" description: "My cpuscaler application" spec: components: - name: my-component type: worker properties: image: my-app-image:v1.0.0 cmd: ["cmd"] cpu: "0.25" memory: "200Mi" traits: - type: cpuscaler # Set to cpuscaler properties: min: 1 # (Required) minimal number of replicas to which the autoscaler can scale down. 1 by default max: 3 # (Required) maximum number of of replicas to which the autoscaler can scale up. 10 by default cpuUtil: 10 # (Required) average CPU utilization. 50% by defaults