Skip to main content
Version: v1.4.x

Cpuscaler

TypeTrait

Parameters​

Parameter
Type
Required
DefaultDescription
cpuUtilintegerYes

50

Specify the average CPU utilization, for example, 50 means the CPU usage is 50%

maxintegerYes

10

Specify the maximum number of of replicas to which the autoscaler can scale up

minintegerYes

1

Specify the minimal number of replicas to which the autoscaler can scale down

targetAPIVersionstringYes

"apps/v1"

Specify the apiVersion of scale target

targetKindstringYes

"Deployment"

Specify the kind of scale target

Template​

The following tabs display the definition's Cue template and the rendered YAML. The rendered YAML is the output of the Cue template when the definition is applied to a cluster.

cpuscaler: {
type: "trait"
annotations: {}
labels: {
"definition.spectrocloud.com/category": "Scaling"
}
description: "Automatically scale the component based on CPU usage."
attributes: {
version: "1.0.1"
}
}

template: {
outputs: cpuscaler: {
apiVersion: "autoscaling/v1"
kind: "HorizontalPodAutoscaler"
metadata: name: context.name
spec: {
scaleTargetRef: {
apiVersion: parameter.targetAPIVersion
kind: parameter.targetKind
name: context.name
}
minReplicas: parameter.min
maxReplicas: parameter.max
targetCPUUtilizationPercentage: parameter.cpuUtil
}
}

parameter: {
// +usage=Specify the minimal number of replicas to which the autoscaler can scale down
min: *1 | int
// +usage=Specify the maximum number of of replicas to which the autoscaler can scale up
max: *10 | int
// +usage=Specify the average CPU utilization, for example, 50 means the CPU usage is 50%
cpuUtil: *50 | int
// +usage=Specify the apiVersion of scale target
targetAPIVersion: *"apps/v1" | string
// +usage=Specify the kind of scale target
targetKind: *"Deployment" | string
}
}