github.com/oam-dev/kubevela@v1.9.11/pkg/controller/core.oam.dev/v1beta1/application/testdata/definitions/hubcpuscaler.yaml (about)

     1  apiVersion: core.oam.dev/v1beta1
     2  kind: TraitDefinition
     3  metadata:
     4    annotations:
     5      definition.oam.dev/description: Automatically scale the component based on CPU usage.
     6    labels:
     7      custom.definition.oam.dev/ui-hidden: "true"
     8    name: hubcpuscaler
     9    namespace: vela-system
    10  spec:
    11    appliesToWorkloads:
    12      - deployments.apps
    13    controlPlaneOnly: true
    14    schematic:
    15      cue:
    16        template: |
    17          outputs: hubcpuscaler: {
    18          	apiVersion: "autoscaling/v1"
    19          	kind:       "HorizontalPodAutoscaler"
    20          	metadata: name: context.name
    21          	spec: {
    22          		scaleTargetRef: {
    23          			apiVersion: parameter.targetAPIVersion
    24          			kind:       parameter.targetKind
    25          			name:       context.name
    26          		}
    27          		minReplicas:                    parameter.min
    28          		maxReplicas:                    parameter.max
    29          		targetCPUUtilizationPercentage: parameter.cpuUtil
    30          	}
    31          }
    32          parameter: {
    33          	// +usage=Specify the minimal number of replicas to which the autoscaler can scale down
    34          	min: *1 | int
    35          	// +usage=Specify the maximum number of of replicas to which the autoscaler can scale up
    36          	max: *10 | int
    37          	// +usage=Specify the average CPU utilization, for example, 50 means the CPU usage is 50%
    38          	cpuUtil: *50 | int
    39          	// +usage=Specify the apiVersion of scale target
    40          	targetAPIVersion: *"apps/v1" | string
    41          	// +usage=Specify the kind of scale target
    42          	targetKind: *"Deployment" | string
    43          }