github.com/oam-dev/kubevela@v1.9.11/vela-templates/registry/auto-gen/autoscale.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/registry/autoscale.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: TraitDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/description: Automatically scales workloads by resource utilization metrics or cron triggers. 8 name: autoscale 9 namespace: vela-system 10 spec: 11 appliesToWorkloads: 12 - deployments.apps 13 definitionRef: 14 name: autoscalers.standard.oam.dev 15 extension: 16 install: 17 helm: 18 name: keda 19 repo: kedacore 20 url: https://kedacore.github.io/charts 21 version: 2.0.0-rc3 22 podDisruptive: true 23 schematic: 24 cue: 25 template: | 26 import "strconv" 27 28 outputs: autoscaler: {{ 29 apiVersion: "standard.oam.dev/v1alpha1" 30 kind: "Autoscaler" 31 spec: { 32 minReplicas: parameter.min 33 maxReplicas: parameter.max 34 if parameter["cpuPercent"] != _|_ && parameter["cron"] != _|_ { 35 triggers: [cpuScaler, cronScaler] 36 } 37 if parameter["cpuPercent"] != _|_ && parameter["cron"] == _|_ { 38 triggers: [cpuScaler] 39 } 40 if parameter["cpuPercent"] == _|_ && parameter["cron"] != _|_ { 41 triggers: [cronScaler] 42 } 43 } 44 }} 45 cpuScaler: { 46 type: "cpu" 47 condition: { 48 type: "Utilization" 49 if parameter["cpuPercent"] != _|_ { 50 // Temporarily use `strconv` for type converting. This bug will be fixed in kubevela#585 51 value: strconv.FormatInt(parameter.cpuPercent, 10) 52 } 53 } 54 } 55 cronScaler: { 56 type: "cron" 57 if parameter["cron"] != _|_ && parameter.cron["replicas"] != _|_ { 58 condition: { 59 startAt: parameter.cron.startAt 60 duration: parameter.cron.duration 61 days: parameter.cron.days 62 replicas: strconv.FormatInt(parameter.cron.replicas, 10) 63 timezone: parameter.cron.timezone 64 } 65 } 66 } 67 parameter: { 68 // +usage=Minimal replicas of the workload 69 min: int 70 // +usage=Maximal replicas of the workload 71 max: int 72 // +usage=Specify the value for CPU utilization, like 80, which means 80% 73 // +alias=cpu-percent 74 cpuPercent?: int 75 // +usage=Cron type auto-scaling. Just for `appfile`, not available for Cli usage 76 cron?: { 77 // +usage=The time to start scaling, like `08:00` 78 startAt: string 79 // +usage=For how long the scaling will last 80 duration: string 81 // +usage=Several workdays or weekends, like "Monday, Tuesday" 82 days: string 83 // +usage=The target replicas to be scaled to 84 replicas: int 85 // +usage=Timezone, like "America/Los_Angeles" 86 timezone: string 87 } 88 } 89 workloadRefPath: spec.workloadRef 90