github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/cpuscaler.yaml (about)

     1  # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
     2  # Definition source cue file: vela-templates/definitions/internal/cpuscaler.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: TraitDefinition
     5  metadata:
     6    annotations:
     7      definition.oam.dev/description: Automatically scale the component based on CPU usage.
     8    name: cpuscaler
     9    namespace: {{ include "systemDefinitionNamespace" . }}
    10  spec:
    11    appliesToWorkloads:
    12      - deployments.apps
    13      - statefulsets.apps
    14    schematic:
    15      cue:
    16        template: |
    17          outputs: cpuscaler: {
    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  
    33          parameter: {
    34          	// +usage=Specify the minimal number of replicas to which the autoscaler can scale down
    35          	min: *1 | int
    36          	// +usage=Specify the maximum number of of replicas to which the autoscaler can scale up
    37          	max: *10 | int
    38          	// +usage=Specify the average CPU utilization, for example, 50 means the CPU usage is 50%
    39          	cpuUtil: *50 | int
    40          	// +usage=Specify the apiVersion of scale target
    41          	targetAPIVersion: *"apps/v1" | string
    42          	// +usage=Specify the kind of scale target
    43          	targetKind: *"Deployment" | string
    44          }
    45