github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/trait/cpuscaler.cue (about) 1 cpuscaler: { 2 type: "trait" 3 annotations: {} 4 description: "Automatically scale the component based on CPU usage." 5 attributes: { 6 appliesToWorkloads: ["deployments.apps", "statefulsets.apps"] 7 } 8 } 9 10 template: { 11 outputs: cpuscaler: { 12 apiVersion: "autoscaling/v1" 13 kind: "HorizontalPodAutoscaler" 14 metadata: name: context.name 15 spec: { 16 scaleTargetRef: { 17 apiVersion: parameter.targetAPIVersion 18 kind: parameter.targetKind 19 name: context.name 20 } 21 minReplicas: parameter.min 22 maxReplicas: parameter.max 23 targetCPUUtilizationPercentage: parameter.cpuUtil 24 } 25 } 26 27 parameter: { 28 // +usage=Specify the minimal number of replicas to which the autoscaler can scale down 29 min: *1 | int 30 // +usage=Specify the maximum number of of replicas to which the autoscaler can scale up 31 max: *10 | int 32 // +usage=Specify the average CPU utilization, for example, 50 means the CPU usage is 50% 33 cpuUtil: *50 | int 34 // +usage=Specify the apiVersion of scale target 35 targetAPIVersion: *"apps/v1" | string 36 // +usage=Specify the kind of scale target 37 targetKind: *"Deployment" | string 38 } 39 }