diff --git a/charts/vela-core/templates/defwithtemplate/autoscale.yaml b/charts/vela-core/templates/defwithtemplate/autoscale.yaml index 36d71b8d7..1dab45898 100644 --- a/charts/vela-core/templates/defwithtemplate/autoscale.yaml +++ b/charts/vela-core/templates/defwithtemplate/autoscale.yaml @@ -8,26 +8,26 @@ spec: appliesToWorkloads: - webservice - backend - - deployments.apps - - podspecworkload workloadRefPath: spec.workloadRef definitionRef: name: autoscalers.standard.oam.dev extension: template: | + import "strconv" + output: { apiVersion: "standard.oam.dev/v1alpha1" kind: "Autoscaler" spec: { minReplicas: parameter.min maxReplicas: parameter.max - if parameter["cpu"] != _|_ && parameter["cron"] != _|_ { + if parameter["cpuPercent"] != _|_ && parameter["cron"] != _|_ { triggers: [cpuScaler, cronScaler] } - if parameter["cpu"] != _|_ && parameter["cron"] == _|_ { + if parameter["cpuPercent"] != _|_ && parameter["cron"] == _|_ { triggers: [cpuScaler] } - if parameter["cpu"] == _|_ && parameter["cron"] != _|_ { + if parameter["cpuPercent"] == _|_ && parameter["cron"] != _|_ { triggers: [cronScaler] } } @@ -37,16 +37,22 @@ spec: type: "cpu" condition: { type: "Utilization" - if parameter["cpu"] != _|_ { - value: parameter.cpu + if parameter["cpuPercent"] != _|_ { + value: strconv.FormatInt(parameter.cpuPercent, 10) } } } cronScaler: { type: "cron" - if parameter["cron"] != _|_ { - condition: parameter.cron + if parameter["cron"] != _|_ && parameter.cron["replicas"] != _|_ { + condition: { + startAt: parameter.cron.startAt + duration: parameter.cron.duration + days: parameter.cron.days + replicas: strconv.FormatInt(parameter.cron.replicas, 10) + timezone: parameter.cron.timezone + } } } @@ -56,15 +62,19 @@ spec: // +usage=maximal replicas of the workload max: int // +usage=specify the value for CPU utilization, like 80, which means 80% - cpu?: string + // +alias=cpu-percent + cpuPercent?: int // +usage=just for `appfile`, not available for Cli usage cron?: { - startAt: string + // +usage=the time to start scaling, like `08:00` + startAt: string + // +usage=for how long the scaling will last duration: string // +usage=several workdays or weekends, like "Monday, Tuesday" - days: string - replicas: string - // +usage=timezone, like "America/Seattle" + days: string + // +usage=the target replicas to be scaled to + replicas: int + // +usage=timezone, like "America/Los_Angeles" timezone: string } } diff --git a/charts/vela-core/templates/defwithtemplate/webservice.yaml b/charts/vela-core/templates/defwithtemplate/webservice.yaml index 0b6697016..d36f81ee4 100644 --- a/charts/vela-core/templates/defwithtemplate/webservice.yaml +++ b/charts/vela-core/templates/defwithtemplate/webservice.yaml @@ -48,12 +48,12 @@ spec: containerPort: parameter.port }] - if parameter["cpuRequests"] != _|_ { + if parameter["cpu"] != _|_ { resources: { limits: - cpu: parameter.cpuRequests + cpu: parameter.cpu requests: - cpu: parameter.cpuRequests + cpu: parameter.cpu } } }] @@ -82,8 +82,7 @@ spec: } } }] - // +usage=CPU core requests for the workload, specify like '0.5', '1'. - // +alias=cpu-requests - cpuRequests?: string + // +usage=Number of CPU units for the service, like `500m` (0.5 CPU core), `1` (1 CPU core) + cpu?: string } diff --git a/docs/en/cli/vela.md b/docs/en/cli/vela.md index e1731a7e5..754e0ed6a 100644 --- a/docs/en/cli/vela.md +++ b/docs/en/cli/vela.md @@ -46,4 +46,4 @@ vela [flags] * [vela version](vela_version.md) - Prints out build version information * [vela workloads](vela_workloads.md) - List workloads -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_autoscale.md b/docs/en/cli/vela_autoscale.md index cfd59fd50..dfc7421e6 100644 --- a/docs/en/cli/vela_autoscale.md +++ b/docs/en/cli/vela_autoscale.md @@ -19,19 +19,13 @@ vela autoscale frontend ### Options ``` - --days string - --detach detach trait from service - --duration string - -h, --help help for autoscale - --maxReplicas int (default 4) - --minReplicas int (default 1) - --name string - --replicas string (default "2") - -s, --staging only save changes locally without real update application - --startAt string - --svc string specify one service belonging to the application - --timezone string (default "Asia/Shanghai") - --type string (default "cron") + --cpuPercent int specify the value for CPU utilization, like 80, which means 80% + --detach detach trait from service + -h, --help help for autoscale + --max int maximal replicas of the workload + --min int minimal replicas of the workload + -s, --staging only save changes locally without real update application + --svc string specify one service belonging to the application ``` ### Options inherited from parent commands @@ -44,4 +38,4 @@ vela autoscale frontend * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap.md b/docs/en/cli/vela_cap.md index 675b3a1dc..e8c7d6605 100644 --- a/docs/en/cli/vela_cap.md +++ b/docs/en/cli/vela_cap.md @@ -26,4 +26,4 @@ Capability Management with config, list, add, remove capabilities * [vela cap ls](vela_cap_ls.md) - List capabilities from cap-center * [vela cap uninstall](vela_cap_uninstall.md) - Uninstall capability from cluster -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_center.md b/docs/en/cli/vela_cap_center.md index ab8c1f139..2813eefc8 100644 --- a/docs/en/cli/vela_cap_center.md +++ b/docs/en/cli/vela_cap_center.md @@ -26,4 +26,4 @@ Manage Capability Center with config, sync, list * [vela cap center remove](vela_cap_center_remove.md) - Remove specified capability center * [vela cap center sync](vela_cap_center_sync.md) - Sync capabilities from remote center, default to sync all centers -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_center_config.md b/docs/en/cli/vela_cap_center_config.md index d96e92409..9b7486805 100644 --- a/docs/en/cli/vela_cap_center_config.md +++ b/docs/en/cli/vela_cap_center_config.md @@ -33,4 +33,4 @@ vela cap center config mycenter https://github.com/oam-dev/catalog/cap-center * [vela cap center](vela_cap_center.md) - Manage Capability Center -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_center_ls.md b/docs/en/cli/vela_cap_center_ls.md index 2ea6897fd..33a536b51 100644 --- a/docs/en/cli/vela_cap_center_ls.md +++ b/docs/en/cli/vela_cap_center_ls.md @@ -32,4 +32,4 @@ vela cap center ls * [vela cap center](vela_cap_center.md) - Manage Capability Center -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_center_remove.md b/docs/en/cli/vela_cap_center_remove.md index 7a990783c..7c2e92a84 100644 --- a/docs/en/cli/vela_cap_center_remove.md +++ b/docs/en/cli/vela_cap_center_remove.md @@ -32,4 +32,4 @@ vela cap center remove mycenter * [vela cap center](vela_cap_center.md) - Manage Capability Center -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_center_sync.md b/docs/en/cli/vela_cap_center_sync.md index 679fbb152..9be0ca3bc 100644 --- a/docs/en/cli/vela_cap_center_sync.md +++ b/docs/en/cli/vela_cap_center_sync.md @@ -32,4 +32,4 @@ vela cap center sync mycenter * [vela cap center](vela_cap_center.md) - Manage Capability Center -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_install.md b/docs/en/cli/vela_cap_install.md index 6598b5abc..26a867ce0 100644 --- a/docs/en/cli/vela_cap_install.md +++ b/docs/en/cli/vela_cap_install.md @@ -33,4 +33,4 @@ vela cap install mycenter/route * [vela cap](vela_cap.md) - Capability Management -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_ls.md b/docs/en/cli/vela_cap_ls.md index 54bbd5010..b84a2e95a 100644 --- a/docs/en/cli/vela_cap_ls.md +++ b/docs/en/cli/vela_cap_ls.md @@ -32,4 +32,4 @@ vela cap ls * [vela cap](vela_cap.md) - Capability Management -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_cap_uninstall.md b/docs/en/cli/vela_cap_uninstall.md index ced158dfc..981c36294 100644 --- a/docs/en/cli/vela_cap_uninstall.md +++ b/docs/en/cli/vela_cap_uninstall.md @@ -33,4 +33,4 @@ vela cap uninstall route * [vela cap](vela_cap.md) - Capability Management -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_completion.md b/docs/en/cli/vela_completion.md index ac64f2bc4..eef370f99 100644 --- a/docs/en/cli/vela_completion.md +++ b/docs/en/cli/vela_completion.md @@ -27,4 +27,4 @@ of vela commands. * [vela completion bash](vela_completion_bash.md) - generate autocompletions script for bash * [vela completion zsh](vela_completion_zsh.md) - generate autocompletions script for zsh -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_completion_bash.md b/docs/en/cli/vela_completion_bash.md index 59cddc993..1c4a13cc7 100644 --- a/docs/en/cli/vela_completion_bash.md +++ b/docs/en/cli/vela_completion_bash.md @@ -36,4 +36,4 @@ vela completion bash * [vela completion](vela_completion.md) - Output shell completion code for the specified shell (bash or zsh) -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_completion_zsh.md b/docs/en/cli/vela_completion_zsh.md index 3373cebc3..e01663eff 100644 --- a/docs/en/cli/vela_completion_zsh.md +++ b/docs/en/cli/vela_completion_zsh.md @@ -33,4 +33,4 @@ vela completion zsh * [vela completion](vela_completion.md) - Output shell completion code for the specified shell (bash or zsh) -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_config.md b/docs/en/cli/vela_config.md index b876cf001..ce6e69988 100644 --- a/docs/en/cli/vela_config.md +++ b/docs/en/cli/vela_config.md @@ -26,4 +26,4 @@ Manage application configurations under given env * [vela config ls](vela_config_ls.md) - List configs * [vela config set](vela_config_set.md) - Set data for a config -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_config_del.md b/docs/en/cli/vela_config_del.md index 6c6a3ce5e..bbff744cd 100644 --- a/docs/en/cli/vela_config_del.md +++ b/docs/en/cli/vela_config_del.md @@ -32,4 +32,4 @@ vela config del * [vela config](vela_config.md) - Manage application configurations -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_config_get.md b/docs/en/cli/vela_config_get.md index c0820b48f..605ef3d64 100644 --- a/docs/en/cli/vela_config_get.md +++ b/docs/en/cli/vela_config_get.md @@ -32,4 +32,4 @@ vela config get * [vela config](vela_config.md) - Manage application configurations -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_config_ls.md b/docs/en/cli/vela_config_ls.md index c945b5953..0a7e1af46 100644 --- a/docs/en/cli/vela_config_ls.md +++ b/docs/en/cli/vela_config_ls.md @@ -32,4 +32,4 @@ vela config ls * [vela config](vela_config.md) - Manage application configurations -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_config_set.md b/docs/en/cli/vela_config_set.md index ff42ab52a..08b969622 100644 --- a/docs/en/cli/vela_config_set.md +++ b/docs/en/cli/vela_config_set.md @@ -32,4 +32,4 @@ vela config set KEY=VALUE K2=V2 * [vela config](vela_config.md) - Manage application configurations -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_dashboard.md b/docs/en/cli/vela_dashboard.md index 599d84b6b..e19182bf4 100644 --- a/docs/en/cli/vela_dashboard.md +++ b/docs/en/cli/vela_dashboard.md @@ -38,4 +38,4 @@ dashboard * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_delete.md b/docs/en/cli/vela_delete.md index 346ddaadd..4c5409e52 100644 --- a/docs/en/cli/vela_delete.md +++ b/docs/en/cli/vela_delete.md @@ -33,4 +33,4 @@ vela delete frontend * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_env.md b/docs/en/cli/vela_env.md index 2b8b203b4..88eb60a74 100644 --- a/docs/en/cli/vela_env.md +++ b/docs/en/cli/vela_env.md @@ -26,4 +26,4 @@ Manage application environments * [vela env ls](vela_env_ls.md) - List environments * [vela env set](vela_env_set.md) - Set an environment -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_env_delete.md b/docs/en/cli/vela_env_delete.md index 21bdd34e0..800016aac 100644 --- a/docs/en/cli/vela_env_delete.md +++ b/docs/en/cli/vela_env_delete.md @@ -32,4 +32,4 @@ vela env delete test * [vela env](vela_env.md) - Manage application environments -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_env_init.md b/docs/en/cli/vela_env_init.md index 9056d75d3..00a4d62ac 100644 --- a/docs/en/cli/vela_env_init.md +++ b/docs/en/cli/vela_env_init.md @@ -36,4 +36,4 @@ vela env init test --namespace test --email my@email.com * [vela env](vela_env.md) - Manage application environments -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_env_ls.md b/docs/en/cli/vela_env_ls.md index 2cb36e8b2..5b49c1c23 100644 --- a/docs/en/cli/vela_env_ls.md +++ b/docs/en/cli/vela_env_ls.md @@ -32,4 +32,4 @@ vela env ls [env-name] * [vela env](vela_env.md) - Manage application environments -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_env_set.md b/docs/en/cli/vela_env_set.md index b5d0465bf..2d0c52346 100644 --- a/docs/en/cli/vela_env_set.md +++ b/docs/en/cli/vela_env_set.md @@ -32,4 +32,4 @@ vela env set test * [vela env](vela_env.md) - Manage application environments -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_exec.md b/docs/en/cli/vela_exec.md index 7dac64b7c..1e5e11482 100644 --- a/docs/en/cli/vela_exec.md +++ b/docs/en/cli/vela_exec.md @@ -29,4 +29,4 @@ vela exec [flags] AppName -- COMMAND [args...] * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_init.md b/docs/en/cli/vela_init.md index 31e0f0bd9..5aaabebf9 100644 --- a/docs/en/cli/vela_init.md +++ b/docs/en/cli/vela_init.md @@ -33,4 +33,4 @@ vela init * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_install.md b/docs/en/cli/vela_install.md index 46a25a818..c8d1ccb83 100644 --- a/docs/en/cli/vela_install.md +++ b/docs/en/cli/vela_install.md @@ -31,4 +31,4 @@ vela install [flags] * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_logs.md b/docs/en/cli/vela_logs.md index 489efd157..4dbb5e5c2 100644 --- a/docs/en/cli/vela_logs.md +++ b/docs/en/cli/vela_logs.md @@ -27,4 +27,4 @@ vela logs [flags] * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_ls.md b/docs/en/cli/vela_ls.md index 96f7dcf04..953d2a491 100644 --- a/docs/en/cli/vela_ls.md +++ b/docs/en/cli/vela_ls.md @@ -33,4 +33,4 @@ vela ls * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_metric.md b/docs/en/cli/vela_metric.md index b8381c9d5..8e510bf1c 100644 --- a/docs/en/cli/vela_metric.md +++ b/docs/en/cli/vela_metric.md @@ -40,4 +40,4 @@ vela metric frontend * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_port-forward.md b/docs/en/cli/vela_port-forward.md index 58d2423dd..44acb3604 100644 --- a/docs/en/cli/vela_port-forward.md +++ b/docs/en/cli/vela_port-forward.md @@ -28,4 +28,4 @@ vela port-forward APP_NAME [options] [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N: * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_rollout.md b/docs/en/cli/vela_rollout.md index 17e6a9234..1339b51c2 100644 --- a/docs/en/cli/vela_rollout.md +++ b/docs/en/cli/vela_rollout.md @@ -38,4 +38,4 @@ vela rollout frontend * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_route.md b/docs/en/cli/vela_route.md index 7719a2034..6fea05fe7 100644 --- a/docs/en/cli/vela_route.md +++ b/docs/en/cli/vela_route.md @@ -37,4 +37,4 @@ vela route frontend * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_scaler.md b/docs/en/cli/vela_scaler.md index 3460b7959..86d3beb4c 100644 --- a/docs/en/cli/vela_scaler.md +++ b/docs/en/cli/vela_scaler.md @@ -36,4 +36,4 @@ vela scaler frontend * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_show.md b/docs/en/cli/vela_show.md index 3adb26bf3..5f838c83c 100644 --- a/docs/en/cli/vela_show.md +++ b/docs/en/cli/vela_show.md @@ -33,4 +33,4 @@ vela show * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_status.md b/docs/en/cli/vela_status.md index caf8a515b..e7c024fec 100644 --- a/docs/en/cli/vela_status.md +++ b/docs/en/cli/vela_status.md @@ -33,4 +33,4 @@ vela status * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_svc.md b/docs/en/cli/vela_svc.md index 3cf520b1d..914822e8c 100644 --- a/docs/en/cli/vela_svc.md +++ b/docs/en/cli/vela_svc.md @@ -24,4 +24,4 @@ Manage services * [vela](vela.md) - * [vela svc deploy](vela_svc_deploy.md) - Initialize and run a service -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_svc_deploy.md b/docs/en/cli/vela_svc_deploy.md index 9db42e097..c546bf10e 100644 --- a/docs/en/cli/vela_svc_deploy.md +++ b/docs/en/cli/vela_svc_deploy.md @@ -35,4 +35,4 @@ vela svc deploy -t * [vela svc](vela_svc.md) - Manage services -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_system.md b/docs/en/cli/vela_system.md index d854932a1..c35d464f8 100644 --- a/docs/en/cli/vela_system.md +++ b/docs/en/cli/vela_system.md @@ -23,4 +23,4 @@ System management utilities * [vela](vela.md) - * [vela system info](vela_system_info.md) - Show vela client and cluster chartPath -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_system_info.md b/docs/en/cli/vela_system_info.md index 332a13b20..184af355c 100644 --- a/docs/en/cli/vela_system_info.md +++ b/docs/en/cli/vela_system_info.md @@ -26,4 +26,4 @@ vela system info [flags] * [vela system](vela_system.md) - System management utilities -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_template.md b/docs/en/cli/vela_template.md index f2b8fed3b..54d6783f5 100644 --- a/docs/en/cli/vela_template.md +++ b/docs/en/cli/vela_template.md @@ -23,4 +23,4 @@ Manage templates * [vela](vela.md) - * [vela template context](vela_template_context.md) - Show context parameters -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_template_context.md b/docs/en/cli/vela_template_context.md index e3ac13a3e..e24352318 100644 --- a/docs/en/cli/vela_template_context.md +++ b/docs/en/cli/vela_template_context.md @@ -32,4 +32,4 @@ vela template context * [vela template](vela_template.md) - Manage templates -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_traits.md b/docs/en/cli/vela_traits.md index d426b5929..4fa10a9c2 100644 --- a/docs/en/cli/vela_traits.md +++ b/docs/en/cli/vela_traits.md @@ -34,4 +34,4 @@ vela traits * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_up.md b/docs/en/cli/vela_up.md index 5fe100abb..1488a6e0c 100644 --- a/docs/en/cli/vela_up.md +++ b/docs/en/cli/vela_up.md @@ -27,4 +27,4 @@ vela up * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_version.md b/docs/en/cli/vela_version.md index 05fe579c0..cd5a3bc70 100644 --- a/docs/en/cli/vela_version.md +++ b/docs/en/cli/vela_version.md @@ -26,4 +26,4 @@ vela version [flags] * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/cli/vela_workloads.md b/docs/en/cli/vela_workloads.md index d69250b5e..4cbfcac8b 100644 --- a/docs/en/cli/vela_workloads.md +++ b/docs/en/cli/vela_workloads.md @@ -33,4 +33,4 @@ vela workloads * [vela](vela.md) - -###### Auto generated by spf13/cobra on 10-Nov-2020 +###### Auto generated by spf13/cobra on 12-Nov-2020 diff --git a/docs/en/developers/alternative-cmd.md b/docs/en/developers/alternative-cmd.md index c7c6edfc0..d2f3a40fb 100644 --- a/docs/en/developers/alternative-cmd.md +++ b/docs/en/developers/alternative-cmd.md @@ -142,21 +142,42 @@ Last Deployment: ## `vela autoscale` A shortcut to autoscale the service. +Currently, Cli only supports setting CPU resource utilization auto-scaling policy. To configure cron auto-scaling policy, +please refer to [autoscale in Appfile](/en/developers/set-autoscale.md). -```console -$ vela autoscale helloworld --svc frontend --min 1 --max 5 --cpu 5 -Adding autoscale for app frontend -⠋ Checking Status ... -✅ Application Deployed Successfully! - - Name: frontend - Type: webservice - HEALTHY Ready: 1/1 - Traits: - - ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/0% replicas(min/max/current): 1/5/0 - Last Deployment: - Created at: 2020-11-06 16:10:54 +0800 CST - Updated at: 2020-11-06T16:19:04+08:0 -``` +- Deploy an application + + Run the following command to deploy application `helloworld`. + + ``` + $ vela svc deploy frontend -t webservice -a helloworld --image nginx:1.9.2 --port 80 --cpu=0.05 + App helloworld deployed + ``` + + By default, the replicas of the workload webservice `helloworld` is one. + +- Scale the application by CPU utilization metrics + ``` + $ vela autoscale helloworld --svc frontend --min 1 --max 5 --cpu-percent 5 + Adding autoscale for app frontend + ⠋ Checking Status ... + ✅ Application Deployed Successfully! + - Name: frontend + Type: webservice + HEALTHY Ready: 1/1 + Traits: + - ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/0% replicas(min/max/current): 1/5/0 + Last Deployment: + Created at: 2020-11-06 16:10:54 +0800 CST + Updated at: 2020-11-06T16:19:04+08:0 + ``` + +- Monitor the replicas changing when the application becomes overloaded + + Continue to monitor the replicas changing when the application becoming overloaded. You can use Apache HTTP server + benchmarking tool `ab` to mock many requests to the application as we did in [Autoscalig in Appfile](/en/developers/set-autoscale.md). + + With more and more requests to the application, the replicas gradually increase from one to four. ## `vela metric` diff --git a/docs/en/developers/references/traits/autoscale.md b/docs/en/developers/references/traits/autoscale.md index e69de29bb..8f946e487 100644 --- a/docs/en/developers/references/traits/autoscale.md +++ b/docs/en/developers/references/traits/autoscale.md @@ -0,0 +1,45 @@ +## Description + +`Autoscale` is used to automatically scale workloads by resource utilization metrics and cron + +## Specification + +List of all available properties for a `Autoscale` trait. + +```yaml +name: testapp + +services: +express-server: + + autoscale: + min: 1 + max: 4 + cron: + startAt: "14:00" + duration: "2h" + days: "Monday, Thursday" + replicas: 2 + timezone: "America/Los_Angeles" + cpuPercent: 10 +``` + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + min | int | minimal replicas of the workload | required + max | int | maximal replicas of the workload | required + cpuPercent | int | specify the value for CPU utilization, like 80, which means 80% | + cron | [{Cron}](#Cron) | just for `appfile`, not available for Cli usage | + +### Cron + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + startAt | string | the time to start scaling, like `08:00` | + duration | string | for how long the scaling will last | + days | string | several workdays or weekends, like "Monday, Tuesday" | + replicas | int | the target replicas to be scaled to | + timezone | string | timezone, like "America/Los_Angeles" | + diff --git a/docs/en/developers/references/workload-types/web-service.md b/docs/en/developers/references/workload-types/web-service.md index 515f3593d..674989916 100644 --- a/docs/en/developers/references/workload-types/web-service.md +++ b/docs/en/developers/references/workload-types/web-service.md @@ -19,6 +19,7 @@ services: image: oamdev/testapp:v1 cmd: ["node", "server.js"] port: 8080 + cpu: "0.1" env: - name: FOO value: bar @@ -37,7 +38,7 @@ Name | Type | Description | Notes **Env** | [**[]WebserviceEnv**](#webserviceenv) | | [optional] **Image** | **string** | Which image would you like to use for your service | **Port** | **int32** | Which port do you want customer traffic sent to | [default to 80] -**CpuRequests** | **string** | CPU core requests for the workload, specify like '0.5', '1' | [optional] +**cpu** | **string** | Number of CPU units for the service, like `500m` (0.5 CPU core), `1` (1 CPU core) | [optional] ### WebserviceEnv diff --git a/docs/en/developers/set-autoscale.md b/docs/en/developers/set-autoscale.md index f8ac20648..1c280418b 100644 --- a/docs/en/developers/set-autoscale.md +++ b/docs/en/developers/set-autoscale.md @@ -1,162 +1,208 @@ # Automatically scale workloads by resource utilization metrics and cron -## Scale by CPU resource utilization metrics +## Setting cron auto-scaling policy +Introduce how to automatically scale workloads by cron. -1. Prepare Appfile: +1. Prepare Appfile - ```bash - $ cat < vela.yaml - name: testapp - - services: - express-server: - image: nginx:1.9.2 - - port: 80 - cpuRequests: 0.05 - - autoscale: - min: 1 - max: 5 - cpu: 5 - EOF + ```yaml + name: testapp + + services: + express-server: + # this image will be used in both build and deploy steps + image: oamdev/testapp:v1 + + cmd: ["node", "server.js"] + port: 8080 + + autoscale: + min: 1 + max: 4 + cron: + startAt: "14:00" + duration: "2h" + days: "Monday, Thursday" + replicas: 2 + timezone: "America/Los_Angeles" ``` -2. Deploy the application: - - ```bash - $ vela up - ``` - -3. Access the application with heavy requests +2. Deploy an application ``` - $ vela port-forward helloworld 80 - Forwarding from 127.0.0.1:80 -> 80 - Forwarding from [::1]:80 -> 80 + $ vela up + Parsing vela.yaml ... + Loading templates ... - Forward successfully! Opening browser ... - Handling connection for 80 + Rendering configs for service (express-server)... + Writing deploy config to (.vela/deploy.yaml) + + Applying deploy configs ... + Checking if app has been deployed... + App has not been deployed, creating a new deployment... + ✅ App has been deployed 🚀🚀🚀 + Port forward: vela port-forward testapp + SSH: vela exec testapp + Logging: vela logs testapp + App status: vela status testapp + Service status: vela status testapp --svc express-server ``` + +3. Check the replicas and wait for the scaling to take effect + + Check the replicas of the application, there is one replica. + + ``` + $ vela status testapp + About: - On your macOS, you might need to add `sudo` ahead of the command. + Name: testapp + Namespace: default + Created at: 2020-11-05 17:09:02.426632 +0800 CST + Updated at: 2020-11-05 17:09:02.426632 +0800 CST -4. Use Apache HTTP server benchmarking tool `ab` to access the application. + Services: - ``` - $ ab -n 10000 -c 200 http://127.0.0.1/ - This is ApacheBench, Version 2.3 <$Revision: 1843412 $> - Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ - Licensed to The Apache Software Foundation, http://www.apache.org/ - - Benchmarking 127.0.0.1 (be patient) - Completed 1000 requests - ``` - -5. Monitor the replicas of the workload, and see its replicas increase from one to four. - - ``` - $ vela status helloworld --svc frontend - About: - - Name: helloworld - Namespace: default - Created at: 2020-11-05 20:07:21.830118 +0800 CST - Updated at: 2020-11-05 20:50:42.664725 +0800 CST - - Services: - - - Name: frontend - Type: webservice - HEALTHY Ready: 1/1 - Traits: - - ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/14% replicas(min/max/current): 1/5/4 - Last Deployment: - Created at: 2020-11-05 20:07:23 +0800 CST - Updated at: 2020-11-05T20:50:42+08:00 - ``` - - Stop `ab` tool, and the replicas will decrease to one eventually. - - -## Scale workload by cron - -1. Prepare Appfile: - - ```bash - $ cat < vela.yaml - name: testapp - - services: - express-server: - image: zzxwill/kubevela-appfile-demo:v1 - - cmd: ["node", "server.js"] - port: 8080 - - autoscale: - min: 1 - max: 4 - cron: - startAt: "14:00" - duration: "2h" - days: "Monday, Thursday" - replicas: "2" - timezone: "America/Seattle" - EOF - ``` - -2. Deploy the application: - - ```bash - $ vela up - ``` - -3. Check the replicas and wait for the scaling to take effect: - - ``` - $ vela status testapp - About: - - Name: testapp - Namespace: default - Created at: 2020-11-05 17:09:02.426632 +0800 CST - Updated at: 2020-11-05 17:09:02.426632 +0800 CST - - Services: - - - Name: express-server - Type: webservice - HEALTHY Ready: 1/1 - Traits: - - ✅ autoscale: type: cron replicas(min/max/current): 1/4/1 - Last Deployment: - Created at: 2020-11-05 17:09:03 +0800 CST - Updated at: 2020-11-05T17:09:02+08:00 + - Name: express-server + Type: webservice + HEALTHY Ready: 1/1 + Traits: + - ✅ autoscale: type: cron replicas(min/max/current): 1/4/1 + Last Deployment: + Created at: 2020-11-05 17:09:03 +0800 CST + Updated at: 2020-11-05T17:09:02+08:00 ``` Wait till the time clocks `startAt`, and check again. The replicas become to two, which is specified as `replicas` in `vela.yaml`. ``` - $ vela status testapp - About: - - Name: testapp - Namespace: default - Created at: 2020-11-10 10:18:59.498079 +0800 CST - Updated at: 2020-11-10 10:18:59.49808 +0800 CST - - Services: - - - Name: express-server - Type: webservice - HEALTHY Ready: 2/2 - Traits: - - ✅ autoscale: type: cron replicas(min/max/current): 1/4/2 - Last Deployment: - Created at: 2020-11-10 10:18:59 +0800 CST - Updated at: 2020-11-10T10:18:59+08:00 + $ vela status testapp + About: + + Name: testapp + Namespace: default + Created at: 2020-11-10 10:18:59.498079 +0800 CST + Updated at: 2020-11-10 10:18:59.49808 +0800 CST + + Services: + + - Name: express-server + Type: webservice + HEALTHY Ready: 2/2 + Traits: + - ✅ autoscale: type: cron replicas(min/max/current): 1/4/2 + Last Deployment: + Created at: 2020-11-10 10:18:59 +0800 CST + Updated at: 2020-11-10T10:18:59+08:00 ``` Wait after the period ends, the replicas will be one eventually. + +## Setting auto-scaling policy of CPU resource utilization +Introduce how to automatically scale workloads by CPU resource utilization. + +1. Prepare Appfile + + Modify `vela.yaml` as below. We add field `services.express-server.cpu` and change the auto-scaling policy + from cron to cpu utilization by updating filed `services.express-server.autoscale`. + + ```yaml + name: testapp + + services: + express-server: + image: oamdev/testapp:v1 + + cmd: ["node", "server.js"] + port: 8080 + cpu: "0.01" + + autoscale: + min: 1 + max: 5 + cpuPercent: 10 + ``` + +2. Deploy an application + + ```bash + $ vela up + ``` + +3. Expose the service entrypoint of the application + + ``` + $ vela port-forward helloworld 80 + Forwarding from 127.0.0.1:80 -> 80 + Forwarding from [::1]:80 -> 80 + + Forward successfully! Opening browser ... + Handling connection for 80 + Handling connection for 80 + Handling connection for 80 + Handling connection for 80 + ``` + + On your macOS, you might need to add `sudo` ahead of the command. + +4. Monitor the replicas changing + + Continue to monitor the replicas changing when the application becomes overloaded. You can use Apache HTTP server + benchmarking tool `ab` to mock many requests to the application. + + ``` + $ ab -n 10000 -c 200 http://127.0.0.1/ + This is ApacheBench, Version 2.3 <$Revision: 1843412 $> + Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ + Licensed to The Apache Software Foundation, http://www.apache.org/ + + Benchmarking 127.0.0.1 (be patient) + Completed 1000 requests + ``` + + The replicas gradually increase from one to four. + + ``` + $ vela status helloworld --svc frontend + About: + + Name: helloworld + Namespace: default + Created at: 2020-11-05 20:07:21.830118 +0800 CST + Updated at: 2020-11-05 20:50:42.664725 +0800 CST + + Services: + + - Name: frontend + Type: webservice + HEALTHY Ready: 1/1 + Traits: + - ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/10% replicas(min/max/current): 1/5/2 + Last Deployment: + Created at: 2020-11-05 20:07:23 +0800 CST + Updated at: 2020-11-05T20:50:42+08:00 + ``` + + ``` + $ vela status helloworld --svc frontend + About: + + Name: helloworld + Namespace: default + Created at: 2020-11-05 20:07:21.830118 +0800 CST + Updated at: 2020-11-05 20:50:42.664725 +0800 CST + + Services: + + - Name: frontend + Type: webservice + HEALTHY Ready: 1/1 + Traits: + - ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/14% replicas(min/max/current): 1/5/4 + Last Deployment: + Created at: 2020-11-05 20:07:23 +0800 CST + Updated at: 2020-11-05T20:50:42+08:00 + ``` + + Stop `ab` tool, and the replicas will decrease to one eventually. diff --git a/docs/examples/testapp/vela.yaml b/docs/examples/testapp/vela.yaml index ea73969e4..a1a813a89 100644 --- a/docs/examples/testapp/vela.yaml +++ b/docs/examples/testapp/vela.yaml @@ -43,8 +43,8 @@ services: # startAt: "14:00" # duration: "2h" # days: "Monday, Thursday" - # replicas: "2" - # timezone: "America/Seattle" + # replicas: 2 + # timezone: "America/Los_Angeles" # pi: # image: perl diff --git a/e2e/commonContext.go b/e2e/commonContext.go index fcaaa84fd..77f38c1d5 100644 --- a/e2e/commonContext.go +++ b/e2e/commonContext.go @@ -286,7 +286,7 @@ var ( a: "8080", }, { - q: "CPU core requests for the workload, specify like '0.5', '1'. (optional):", + q: "Number of CPU units for the service, like `500m` (0.5 CPU core), `1` (1 CPU core) (optional):", a: "0.5", }, } diff --git a/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/README.md b/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/README.md deleted file mode 100644 index c086765ab..000000000 --- a/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/README.md +++ /dev/null @@ -1,106 +0,0 @@ -# Scaling PodSpecWorkload with cron and cpu utilization metrics - -## Prerequisites -- [ ] HPA with metrics-server enabled -- [ ] [KEDA](https://keda.sh/docs/2.0/deploy/) v2.0 Beta - -## Deploy deployment and KEDA - - Apply these manifests to deploy PodSpecWorkload with Trait Autoscaler - ``` - $ kubectl apply -f . - ``` - - - Check the replicas of the Deployment generated by PodSpecWorkload - ``` - $ kubectl get deployment --watch - NAME READY UP-TO-DATE AVAILABLE AGE - component-scaler 0/1 0 0 0s - component-scaler 0/1 0 0 0s - component-scaler 0/1 0 0 0s - component-scaler 0/1 0 0 0s - component-scaler 0/1 1 0 0s - component-scaler 1/1 1 1 1s - component-scaler 1/1 1 1 28s - component-scaler 1/2 1 1 40s - component-scaler 1/2 1 1 40s - component-scaler 1/2 1 1 40s - component-scaler 1/2 2 1 40s - component-scaler 2/2 2 2 41s - ``` - - - Wait `ScaledObject` to take effect - ``` - $ kubectl get scaledobject.keda.sh --watch - trait-scaler component-scaler cron Unknown Unknown 0s - trait-scaler component-scaler cron Unknown Unknown 0s - trait-scaler apps/v1.Deployment component-scaler cron Unknown Unknown 0s - trait-scaler apps/v1.Deployment component-scaler cron Unknown Unknown 0s - trait-scaler apps/v1.Deployment component-scaler cron True Unknown 0s - trait-scaler apps/v1.Deployment component-scaler cron True Unknown 0s - trait-scaler apps/v1.Deployment component-scaler cron True True 1s - trait-scaler apps/v1.Deployment component-scaler cron True True 31s - ``` - The replicas of Deployment will change to 4. - ```shell - $ kubectl get deployment --watch - component-scaler 2/4 2 2 5m47s - component-scaler 2/4 2 2 5m47s - component-scaler 2/4 2 2 5m47s - component-scaler 2/4 4 2 5m47s - component-scaler 3/4 4 3 5m59s - component-scaler 4/4 4 4 5m59s - ``` - - - Visit the Deployment with a heavy load. - ``` - $ sudo k port-forward deploy/component-scaler 80 - $ ab -n 10000 -c 100 http://127.0.0.1/ - ``` - - - Monitor the Deployment - The replicas of the Deployment changes from 4 to 8, and to 10 at last. And after stopping ab, it will be scaled down - to 4. - ```shell - component-scaler 4/8 4 4 7m5s - component-scaler 4/8 4 4 7m5s - component-scaler 4/8 4 4 7m5s - component-scaler 4/8 8 4 7m6s - component-scaler 5/8 8 5 7m16s - component-scaler 6/8 8 6 7m16s - component-scaler 7/8 8 7 7m16s - component-scaler 8/8 8 8 7m16s - component-scaler 8/10 8 8 7m20s - component-scaler 8/10 8 8 7m20s - component-scaler 8/10 8 8 7m20s - component-scaler 8/10 10 8 7m20s - component-scaler 9/10 10 9 7m22s - component-scaler 10/10 10 10 7m22s - component-scaler 10/4 10 10 12m - component-scaler 10/4 10 10 12m - component-scaler 8/4 8 8 12m - component-scaler 4/4 4 4 12m - ``` - -# Debug - - KEDA ScaledObject won't be ready - ``` - $ kubectl get scaledobject.keda.sh - NAME SCALETARGETKIND SCALETARGETNAME TRIGGERS AUTHENTICATION READY ACTIVE AGE - trait-scaler component-scaler cron 3m49s - ``` - - Please check those Pods of Keda. - ``` - $ kubectl get pods -n keda - NAME READY STATUS RESTARTS AGE - keda-operator-6d89f67964-smksp 0/1 CrashLoopBackOff 8 22m - keda-operator-metrics-apiserver-77598644dd-w7th5 1/1 Running 0 22m - ``` - - Try to fix the issue, and those Pods will become `READY`. - ``` - k get pods -n keda - NAME READY STATUS RESTARTS AGE - keda-operator-695d978ddb-w5qct 1/1 Running 0 7m53s - keda-operator-metrics-apiserver-77598644dd-f4fjq 1/1 Running 0 7m53s - ``` \ No newline at end of file diff --git a/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/sample_application_config.yaml b/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/sample_application_config.yaml deleted file mode 100644 index b1075fbff..000000000 --- a/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/sample_application_config.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: ApplicationConfiguration -metadata: - name: appconfig-scaler -spec: - components: - - componentName: component-scaler - traits: - - trait: - apiVersion: standard.oam.dev/v1alpha1 - kind: Autoscaler - metadata: - name: trait-scaler - spec: - minReplicas: 1 - maxReplicas: 10 - triggers: - - name: weekday-cron - enabled: true - type: cron - condition: - startAt: "22:47" - duration: 1m - days: "Monday, Tuesday" - replicas: "3" - timezone: Asia/Shanghai - - type: cpu - name: my-cpu-con - enabled: true - condition: - type: Utilization - value: "70" \ No newline at end of file diff --git a/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/sample_component.yaml b/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/sample_component.yaml deleted file mode 100644 index ef3b36407..000000000 --- a/e2e/raw-objects/samples/autoscalers/PodSpecWorkload/sample_component.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: Component -metadata: - name: component-scaler -spec: - workload: - apiVersion: standard.oam.dev/v1alpha1 - kind: PodSpecWorkload - spec: - podSpec: - containers: - - name: nginx-scaler - image: nginx:1.9.4 - ports: - - containerPort: 80 - name: nginx - resources: - limits: - cpu: "1" - requests: - cpu: "0.1" diff --git a/e2e/raw-objects/samples/autoscalers/cron/PodSpecWorkload/sample_application_config.yaml b/e2e/raw-objects/samples/autoscalers/cron/PodSpecWorkload/sample_application_config.yaml deleted file mode 100644 index e2ac4ba82..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/PodSpecWorkload/sample_application_config.yaml +++ /dev/null @@ -1,35 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: ApplicationConfiguration -metadata: - name: appconfig-scaler -spec: - components: - - componentName: component-scaler - traits: - - trait: - apiVersion: standard.oam.dev/v1alpha1 - kind: Autoscaler - metadata: - name: trait-scaler - spec: - minReplicas: 1 - maxReplicas: 10 - triggers: - - name: weekday-cron - enabled: true - type: cron - condition: - startAt: "22:47" - duration: 1m - days: "Monday, Tuesday" - replicas: "3" - timezone: Asia/Shanghai - - name: weekday-cron-2 - enabled: true - type: cron - condition: - startAt: "22:49" - duration: 2m - days: "Monday" - replicas: "1" - timezone: Asia/Shanghai \ No newline at end of file diff --git a/e2e/raw-objects/samples/autoscalers/cron/PodSpecWorkload/sample_component.yaml b/e2e/raw-objects/samples/autoscalers/cron/PodSpecWorkload/sample_component.yaml deleted file mode 100644 index 22fd2a6a5..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/PodSpecWorkload/sample_component.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: Component -metadata: - name: component-scaler -spec: - workload: - apiVersion: standard.oam.dev/v1alpha1 - kind: PodSpecWorkload - spec: - podSpec: - containers: - - name: nginx-scaler - image: nginx:1.9.4 - ports: - - containerPort: 80 - name: nginx diff --git a/e2e/raw-objects/samples/autoscalers/cron/cr-itself/README.md b/e2e/raw-objects/samples/autoscalers/cron/cr-itself/README.md deleted file mode 100644 index 71b9966b6..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/cr-itself/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# cron type Autoscaler - -- Apply manifest -``` -$ kubectl apply -f standard_v1alpha2_autoscaler.yaml - -$ kubectl describe scaledobjects.keda.sh example-scaler -Name: example-scaler -Namespace: default -Labels: scaledObjectName=example-scaler -Annotations: -API Version: keda.sh/v1alpha1 -Kind: ScaledObject -Metadata: - Creation Timestamp: 2020-09-28T09:47:11Z - Finalizers: - finalizer.keda.sh - Generation: 1 - Owner References: - API Version: standard.oam.dev/v1alpha1 - Block Owner Deletion: true - Controller: true - Kind: Autoscaler - Name: example-scaler - UID: 8ae85eb2-6f1c-4d9e-892c-6af22fa2fac5 - Resource Version: 478397 - Self Link: /apis/keda.sh/v1alpha1/namespaces/default/scaledobjects/example-scaler - UID: 6c02a685-92e4-4667-84f5-c9d781385cbf -Spec: - Max Replica Count: 4 - Min Replica Count: 2 - Scale Target Ref: - Name: php-apache - Triggers: - Metadata: - Desired Replicas: 4 - End: 48 19 * * 1 - Start: 48 17 * * 1 - Timezone: Asia/Shanghai - Name: weekend-cron - Type: cron - Metadata: - Desired Replicas: 4 - End: 48 19 * * 6 - Start: 48 17 * * 6 - Timezone: Asia/Shanghai - Name: weekend-cron - Type: cron -Status: - Conditions: - Message: ScaledObject is defined correctly and is ready for scaling - Reason: ScaledObjectReady - Status: True - Type: Ready - Message: Scaling is not performed because triggers are not active - Reason: ScalerNotActive - Status: False - Type: Active - External Metric Names: - cron-Asia-Shanghai-4817xx1-4819xx1 - cron-Asia-Shanghai-4817xx6-4819xx6 - Original Replica Count: 3 - Scale Target GVKR: - Group: apps - Kind: Deployment - Resource: deployments - Version: v1 - Scale Target Kind: apps/v1.Deployment -Events: -``` - -- Monitor KEDA ScaledObject and target deployment -``` -$ kubectl get scaledobjects.keda.sh --watch -NAME SCALETARGETKIND SCALETARGETNAME TRIGGERS AUTHENTICATION READY ACTIVE AGE -example-scaler php-apache cron 0s -example-scaler php-apache cron 0s -example-scaler php-apache cron Unknown Unknown 0s -example-scaler php-apache cron Unknown Unknown 0s -example-scaler apps/v1.Deployment php-apache cron Unknown Unknown 0s -example-scaler apps/v1.Deployment php-apache cron Unknown Unknown 0s -example-scaler apps/v1.Deployment php-apache cron True Unknown 0s -example-scaler apps/v1.Deployment php-apache cron True False 0s -example-scaler apps/v1.Deployment php-apache cron True False 60s -example-scaler apps/v1.Deployment php-apache cron True True 60s -``` - -``` -$ kubectl get deploy php-apache --watch -NAME READY UP-TO-DATE AVAILABLE AGE -php-apache 3/3 3 3 4m41s -php-apache 3/4 3 3 7m11s -php-apache 3/4 3 3 7m11s -php-apache 3/4 3 3 7m11s -php-apache 3/4 4 3 7m11s -php-apache 4/4 4 4 7m12s -``` \ No newline at end of file diff --git a/e2e/raw-objects/samples/autoscalers/cron/cr-itself/standard_v1alpha2_autoscaler.yaml b/e2e/raw-objects/samples/autoscalers/cron/cr-itself/standard_v1alpha2_autoscaler.yaml deleted file mode 100644 index a9b05c816..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/cr-itself/standard_v1alpha2_autoscaler.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: standard.oam.dev/v1alpha1 -kind: Autoscaler -metadata: - name: example-scaler -spec: - minReplicas: 2 # optional, Defaults: 1 - maxReplicas: 6 # optional, cannot be less that minReplicas - triggers: - - name: weekend-cron - enabled: true - type: cron # cron scaler. 表明 scaler 是 KEDA - condition: - startAt: "10:14" # required. "HHMM" - duration: 2h # required. 持续时长;start hour + duration < 24 - days: "Monday,Saturday" # optional. In which days the condition will take effect - replicas: "5" # optional. - timezone: Asia/Shanghai # optional. time zone - targetWorkload: # workloadRef # set by users or be auto-patched by outsiders, like OAM - name: "php-apache" - apiVersion: "extensions/v1beta1" # optional - kind: "Deployment" # optional - diff --git a/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_application_config.yaml b/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_application_config.yaml deleted file mode 100644 index e912accbf..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_application_config.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: ApplicationConfiguration -metadata: - name: appconfig-scaler -spec: - components: - - componentName: component-scaler - traits: - - trait: - apiVersion: standard.oam.dev/v1alpha1 - kind: Autoscaler - metadata: - name: trait-scaler - spec: - minReplicas: 2 - maxReplicas: 8 - triggers: - - name: weekend-cron - enabled: true - type: cron - condition: - startAt: "16:30" - duration: 2h - days: "Friday,Saturday" - replicas: "4" - timezone: "Asia/Shanghai" diff --git a/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_component.yaml b/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_component.yaml deleted file mode 100644 index 7167a15bb..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_component.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: Component -metadata: - name: component-scaler -spec: - workload: - apiVersion: apps/v1 - kind: Deployment - spec: - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - name: nginx-scaler - image: nginx:1.9.4 - ports: - - containerPort: 80 - name: nginx diff --git a/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_workloaddefinition_deployment.yaml b/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_workloaddefinition_deployment.yaml deleted file mode 100644 index 35f7993b6..000000000 --- a/e2e/raw-objects/samples/autoscalers/cron/deployment/sample_workloaddefinition_deployment.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition -metadata: - name: deployments.apps -spec: - definitionRef: - name: deployments.apps \ No newline at end of file diff --git a/hack/vela-templates/cue/autoscale.cue b/hack/vela-templates/cue/autoscale.cue index 01c33cca1..0f3992ea9 100644 --- a/hack/vela-templates/cue/autoscale.cue +++ b/hack/vela-templates/cue/autoscale.cue @@ -1,16 +1,18 @@ +import "strconv" + output: { apiVersion: "standard.oam.dev/v1alpha1" kind: "Autoscaler" spec: { minReplicas: parameter.min maxReplicas: parameter.max - if parameter["cpu"] != _|_ && parameter["cron"] != _|_ { + if parameter["cpuPercent"] != _|_ && parameter["cron"] != _|_ { triggers: [cpuScaler, cronScaler] } - if parameter["cpu"] != _|_ && parameter["cron"] == _|_ { + if parameter["cpuPercent"] != _|_ && parameter["cron"] == _|_ { triggers: [cpuScaler] } - if parameter["cpu"] == _|_ && parameter["cron"] != _|_ { + if parameter["cpuPercent"] == _|_ && parameter["cron"] != _|_ { triggers: [cronScaler] } } @@ -20,16 +22,22 @@ cpuScaler: { type: "cpu" condition: { type: "Utilization" - if parameter["cpu"] != _|_ { - value: parameter.cpu + if parameter["cpuPercent"] != _|_ { + value: strconv.FormatInt(parameter.cpuPercent, 10) } } } cronScaler: { type: "cron" - if parameter["cron"] != _|_ { - condition: parameter.cron + if parameter["cron"] != _|_ && parameter.cron["replicas"] != _|_ { + condition: { + startAt: parameter.cron.startAt + duration: parameter.cron.duration + days: parameter.cron.days + replicas: strconv.FormatInt(parameter.cron.replicas, 10) + timezone: parameter.cron.timezone + } } } @@ -39,15 +47,19 @@ parameter: { // +usage=maximal replicas of the workload max: int // +usage=specify the value for CPU utilization, like 80, which means 80% - cpu?: string + // +alias=cpu-percent + cpuPercent?: int // +usage=just for `appfile`, not available for Cli usage cron?: { - startAt: string + // +usage=the time to start scaling, like `08:00` + startAt: string + // +usage=for how long the scaling will last duration: string // +usage=several workdays or weekends, like "Monday, Tuesday" - days: string - replicas: string - // +usage=timezone, like "America/Seattle" + days: string + // +usage=the target replicas to be scaled to + replicas: int + // +usage=timezone, like "America/Los_Angeles" timezone: string } } diff --git a/hack/vela-templates/cue/webservice.cue b/hack/vela-templates/cue/webservice.cue index c35d90d43..627022f8e 100644 --- a/hack/vela-templates/cue/webservice.cue +++ b/hack/vela-templates/cue/webservice.cue @@ -37,12 +37,12 @@ output: { containerPort: parameter.port }] - if parameter["cpuRequests"] != _|_ { + if parameter["cpu"] != _|_ { resources: { limits: - cpu: parameter.cpuRequests + cpu: parameter.cpu requests: - cpu: parameter.cpuRequests + cpu: parameter.cpu } } }] @@ -71,7 +71,6 @@ parameter: { } } }] - // +usage=CPU core requests for the workload, specify like '0.5', '1'. - // +alias=cpu-requests - cpuRequests?: string + // +usage=Number of CPU units for the service, like `500m` (0.5 CPU core), `1` (1 CPU core) + cpu?: string } diff --git a/hack/vela-templates/definitions/autoscale.yaml b/hack/vela-templates/definitions/autoscale.yaml index e62de391f..3cf897d5d 100644 --- a/hack/vela-templates/definitions/autoscale.yaml +++ b/hack/vela-templates/definitions/autoscale.yaml @@ -8,8 +8,6 @@ spec: appliesToWorkloads: - webservice - backend - - deployments.apps - - podspecworkload workloadRefPath: spec.workloadRef definitionRef: name: autoscalers.standard.oam.dev diff --git a/pkg/cue/convert_test.go b/pkg/cue/convert_test.go index 5312fc1e8..4d98695ef 100644 --- a/pkg/cue/convert_test.go +++ b/pkg/cue/convert_test.go @@ -73,7 +73,7 @@ func TestGetParameter(t *testing.T) { {Name: "image", Short: "i", Required: true, Usage: "Which image would you like to use for your service", Default: "", Type: cue.StringKind}, {Name: "port", Short: "p", Required: false, Usage: "Which port do you want customer traffic sent to", Default: int64(8080), Type: cue.IntKind}, - {Name: "cpuRequests", Short: "", Required: false, Usage: "", Default: "", Type: cue.StringKind}}, + {Name: "cpu", Short: "", Required: false, Usage: "", Default: "", Type: cue.StringKind}}, params) params, err = GetParameters("testdata/workloads/test-param.cue") diff --git a/pkg/cue/testdata/workloads/deployment.cue b/pkg/cue/testdata/workloads/deployment.cue index 851321be4..144530e4c 100644 --- a/pkg/cue/testdata/workloads/deployment.cue +++ b/pkg/cue/testdata/workloads/deployment.cue @@ -10,7 +10,7 @@ name: string value: string }] - cpuRequests?: string + cpu?: string } output: { apiVersion: "apps/v1" @@ -33,12 +33,12 @@ output: { protocol: "TCP" name: "default" }] - if parameter["cpuRequests"] != _|_ { + if parameter["cpu"] != _|_ { resources: { limits: - cpu: parameter.cpuRequests + cpu: parameter.cpu requests: - cpu: parameter.cpuRequests + cpu: parameter.cpu } } }]