-
Notifications
You must be signed in to change notification settings - Fork 133
feat(autoscaling): add support for v1alpha1 #3159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0a94f11
feat(autoscaling): add support for v1alpha1
yfodil e5b9b2b
lint
yfodil c502b6f
Merge branch 'master' into feat/add-autoscaling-group
yfodil 516c389
lint
yfodil c5c39b7
Merge branch 'feat/add-autoscaling-group' of github.com:yfodil/terraf…
yfodil 4185dd1
Merge branch 'master' into feat/add-autoscaling-group
yfodil cc0ab03
Merge branch 'master' into feat/add-autoscaling-group
yfodil 53d6c2d
Fix format
remyleone 39f2c44
Merge branch 'master' into feat/add-autoscaling-group
remyleone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ jobs: | |
| products: | ||
| - account | ||
| - applesilicon | ||
| - autoscaling | ||
| - az | ||
| - baremetal | ||
| - billing | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| --- | ||
| subcategory: "Autoscaling" | ||
| page_title: "Scaleway: scaleway_autoscaling_instance_group" | ||
| --- | ||
|
|
||
| # Resource: scaleway_autoscaling_instance_group | ||
|
|
||
| Books and manages Autoscaling Instance groups. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ### Basic | ||
|
|
||
| ```terraform | ||
| resource "scaleway_autoscaling_instance_group" "main" { | ||
| name = "asg-group" | ||
| template_id = scaleway_autoscaling_instance_template.main.id | ||
| tags = ["terraform-test", "instance-group"] | ||
| capacity { | ||
| max_replicas = 5 | ||
| min_replicas = 1 | ||
| cooldown_delay = "300" | ||
| } | ||
| load_balancer { | ||
| id = scaleway_lb.main.id | ||
| backend_ids = [scaleway_lb_backend.main.id] | ||
| private_network_id = scaleway_vpc_private_network.main.id | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### With template and policies | ||
|
|
||
| ```terraform | ||
| resource "scaleway_vpc" "main" { | ||
| name = "TestAccAutoscalingVPC" | ||
| } | ||
|
|
||
| resource "scaleway_vpc_private_network" "main" { | ||
| name = "TestAccAutoscalingVPC" | ||
| vpc_id = scaleway_vpc.main.id | ||
| } | ||
|
|
||
| resource "scaleway_block_volume" "main" { | ||
| iops = 5000 | ||
| size_in_gb = 10 | ||
| } | ||
|
|
||
| resource "scaleway_block_snapshot" "main" { | ||
| name = "test-ds-block-snapshot-basic" | ||
| volume_id = scaleway_block_volume.main.id | ||
| } | ||
|
|
||
| resource "scaleway_lb_ip" "main" {} | ||
| resource "scaleway_lb" "main" { | ||
| ip_id = scaleway_lb_ip.main.id | ||
| name = "test-lb" | ||
| type = "lb-s" | ||
| private_network { | ||
| private_network_id = scaleway_vpc_private_network.main.id | ||
| } | ||
| } | ||
|
|
||
| resource "scaleway_lb_backend" "main" { | ||
| lb_id = scaleway_lb.main.id | ||
| forward_protocol = "tcp" | ||
| forward_port = 80 | ||
| proxy_protocol = "none" | ||
| } | ||
|
|
||
| resource "scaleway_autoscaling_instance_template" "main" { | ||
| name = "autoscaling-instance-template-basic" | ||
| commercial_type = "PLAY2-MICRO" | ||
| tags = ["terraform-test", "basic"] | ||
| volumes { | ||
| name = "as-volume" | ||
| volume_type = "sbs" | ||
| boot = true | ||
| from_snapshot { | ||
| snapshot_id = scaleway_block_snapshot.main.id | ||
| } | ||
| perf_iops = 5000 | ||
| } | ||
| public_ips_v4_count = 1 | ||
| private_network_ids = [scaleway_vpc_private_network.main.id] | ||
| } | ||
|
|
||
| resource "scaleway_autoscaling_instance_group" "main" { | ||
| name = "autoscaling-instance-group-basic" | ||
| template_id = scaleway_autoscaling_instance_template.main.id | ||
| tags = ["terraform-test", "instance-group"] | ||
| capacity { | ||
| max_replicas = 5 | ||
| min_replicas = 1 | ||
| cooldown_delay = "300" | ||
| } | ||
| load_balancer { | ||
| id = scaleway_lb.main.id | ||
| backend_ids = [scaleway_lb_backend.main.id] | ||
| private_network_id = scaleway_vpc_private_network.main.id | ||
| } | ||
| delete_servers_on_destroy = true | ||
| } | ||
|
|
||
| resource "scaleway_autoscaling_instance_policy" "up" { | ||
| instance_group_id = scaleway_autoscaling_instance_group.main.id | ||
| name = "scale-up-if-cpu-high" | ||
| action = "scale_up" | ||
| type = "flat_count" | ||
| value = 1 | ||
| priority = 1 | ||
|
|
||
| metric { | ||
| name = "cpu scale up" | ||
| managed_metric = "managed_metric_instance_cpu" | ||
| operator = "operator_greater_than" | ||
| aggregate = "aggregate_average" | ||
| sampling_range_min = 5 | ||
| threshold = 70 | ||
| } | ||
| } | ||
|
|
||
| resource "scaleway_autoscaling_instance_policy" "down" { | ||
| instance_group_id = scaleway_autoscaling_instance_group.main.id | ||
| name = "scale-down-if-cpu-low" | ||
| action = "scale_down" | ||
| type = "flat_count" | ||
| value = 1 | ||
| priority = 2 | ||
|
|
||
| metric { | ||
| name = "cpu scale down" | ||
| managed_metric = "managed_metric_instance_cpu" | ||
| operator = "operator_less_than" | ||
| aggregate = "aggregate_average" | ||
| sampling_range_min = 5 | ||
| threshold = 40 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| The following arguments are supported: | ||
|
|
||
| - `template_id` - (Required) The ID of the Instance template to attach to the Instance group. | ||
| - `tags` - (Optional) The tags associated with the Instance group. | ||
| - `name` - (Optional) The Instance group name. | ||
| - `capacity` - (Optional) The specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. | ||
| - `max_replicas` - The maximum count of Instances for the Instance group. | ||
| - `min_replicas` - The minimum count of Instances for the Instance group. | ||
| - `cooldown_delay` - Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. | ||
| - `load_balancer` - (Optional) The specification of the Load Balancer to link to the Instance group. | ||
| - `id` - The ID of the Load Balancer. | ||
| - `backend_ids` - The Load Balancer backend IDs. | ||
| - `private_network_id` - The ID of the Private Network attached to the Load Balancer. | ||
| - `delete_servers_on_destroy` - (Optional) Whether to delete all instances in this group when the group is destroyed. Set to `true` to tear them down, `false` (the default) leaves them running. | ||
| - `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the Instance group exists. | ||
| - `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the Project the Instance group is associated with. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
| In addition to all arguments above, the following attributes are exported: | ||
|
|
||
| - `id` - The ID of the Instance group. | ||
| - `created_at` - Date and time of Instance group's creation (RFC 3339 format). | ||
| - `updated_at` - Date and time of Instance group's last update (RFC 3339 format). | ||
|
|
||
| ~> **Important:** Autoscaling Instance group IDs are [zonal](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111` | ||
|
|
||
| ## Import | ||
|
|
||
| Autoscaling Instance groups can be imported using `{zone}/{id}`, e.g. | ||
|
|
||
| ```bash | ||
| terraform import scaleway_autoscaling_instance_group.main fr-par-1/11111111-1111-1111-1111-111111111111 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| subcategory: "Autoscaling" | ||
| page_title: "Scaleway: scaleway_autoscaling_instance_policy" | ||
| --- | ||
|
|
||
| # Resource: scaleway_autoscaling_instance_policy | ||
|
|
||
| Books and manages Autoscaling Instance policies. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ### Basic | ||
|
|
||
| ```terraform | ||
| resource "scaleway_autoscaling_instance_policy" "up" { | ||
| instance_group_id = scaleway_autoscaling_instance_group.main.id | ||
| name = "scale-up-if-cpu-high" | ||
| action = "scale_up" | ||
| type = "flat_count" | ||
| value = 1 | ||
| priority = 1 | ||
|
|
||
| metric { | ||
| name = "cpu scale up" | ||
| managed_metric = "managed_metric_instance_cpu" | ||
| operator = "operator_greater_than" | ||
| aggregate = "aggregate_average" | ||
| sampling_range_min = 5 | ||
| threshold = 70 | ||
| } | ||
| } | ||
|
|
||
| resource "scaleway_autoscaling_instance_policy" "down" { | ||
| instance_group_id = scaleway_autoscaling_instance_group.main.id | ||
| name = "scale-down-if-cpu-low" | ||
| action = "scale_down" | ||
| type = "flat_count" | ||
| value = 1 | ||
| priority = 2 | ||
|
|
||
| metric { | ||
| name = "cpu scale down" | ||
| managed_metric = "managed_metric_instance_cpu" | ||
| operator = "operator_less_than" | ||
| aggregate = "aggregate_average" | ||
| sampling_range_min = 5 | ||
| threshold = 40 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| The following arguments are supported: | ||
|
|
||
| - `instance_group_id` - (Required) The ID of the Instance group related to this policy. | ||
| - `name` - (Optional) The Instance policy name. | ||
| - `action` - (Required) The action to execute when the metric-based condition is met. | ||
| - `type` - (Required) How to use the number defined in `value` when determining by how many Instances to scale up/down. | ||
| - `value` - (Required) The value representing the magnitude of the scaling action to take for the Instance group. Depending on the `type` parameter, this number could represent a total number of Instances in the group, a number of Instances to add, or a percentage to scale the group by. | ||
| - `priority` - (Required) The priority of this policy compared to all other scaling policies. This determines the processing order. The lower the number, the higher the priority. | ||
| - `metric` - (Optional) Cockpit metric to use when determining whether to trigger a scale up/down action. | ||
| - `name` - Name or description of the metric policy. | ||
| - `operator` - Operator used when comparing the threshold value of the chosen `metric` to the actual sampled and aggregated value. | ||
| - `aggregate` - How the values sampled for the `metric` should be aggregated. | ||
| - `managed_metric` - The managed metric to use for this policy. These are available by default in Cockpit without any configuration or `node_exporter`. The chosen metric forms the basis of the condition that will be checked to determine whether a scaling action should be triggered. | ||
| - `cockpit_metric_name` - The custom metric to use for this policy. This must be stored in Scaleway Cockpit. The metric forms the basis of the condition that will be checked to determine whether a scaling action should be triggered | ||
| - `sampling_range_min` - The Interval of time, in minutes, during which metric is sampled. | ||
| - `threshold` - The threshold value to measure the aggregated sampled `metric` value against. Combined with the `operator` field, determines whether a scaling action should be triggered. | ||
| - `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the Instance policy exists. | ||
| - `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the Project the Instance policy is associated with. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
| In addition to all arguments above, the following attributes are exported: | ||
|
|
||
| - `id` - The ID of the Instance policy. | ||
|
|
||
| ~> **Important:** Autoscaling policies IDs are [zonal](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111` | ||
|
|
||
| ## Import | ||
|
|
||
| Autoscaling instance policies can be imported using `{zone}/{id}`, e.g. | ||
|
|
||
| ```bash | ||
| terraform import scaleway_autoscaling_instance_policy.main fr-par-1/11111111-1111-1111-1111-111111111111 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| subcategory: "Autoscaling" | ||
| page_title: "Scaleway: scaleway_autoscaling_instance_template" | ||
| --- | ||
|
|
||
| # Resource: scaleway_autoscaling_instance_template | ||
|
|
||
| Books and manages Autoscaling Instance templates. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ### Basic | ||
|
|
||
| ```terraform | ||
| resource "scaleway_autoscaling_instance_template" "main" { | ||
| name = "asg-template" | ||
| commercial_type = "PLAY2-MICRO" | ||
| tags = ["terraform-test", "basic"] | ||
| volumes { | ||
| name = "as-volume" | ||
| volume_type = "sbs" | ||
| boot = true | ||
| from_snapshot { | ||
| snapshot_id = scaleway_block_snapshot.main.id | ||
| } | ||
| perf_iops = 5000 | ||
| } | ||
| public_ips_v4_count = 1 | ||
| private_network_ids = [scaleway_vpc_private_network.main.id] | ||
| } | ||
| ``` | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| The following arguments are supported: | ||
|
|
||
| - `commercial_type` - (Required) The name of Instance commercial type. | ||
| - `tags` - (Optional) The tags associated with the Instance template. | ||
| - `name` - (Optional) The Instance group template. | ||
| - `image_id` - (Optional) The instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. | ||
| - `volumes` - (Required) The template of Instance volume. | ||
| - `name` - The name of the volume. | ||
| - `perf_iops` - The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). | ||
| - `tags` - The list of tags assigned to the volume. | ||
| - `boot` - Force the Instance to boot on this volume. | ||
| - `volume_type` - The type of the volume. | ||
| - `security_group_id` - (Optional) The instance security group ID. | ||
| - `placement_group_id` - (Optional) The instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. | ||
| - `public_ips_v4_count` - (Optional) The number of flexible IPv4 addresses to attach to the new Instance. | ||
| - `public_ips_v6_count` - (Optional) The number of flexible IPv6 addresses to attach to the new Instance. | ||
| - `private_network_ids` - (Optional) The private Network IDs to attach to the new Instance. | ||
| - `cloud_init` - (Optional) The instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. | ||
| - `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the Instance template exists. | ||
| - `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the Project the Instance template is associated with. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
| In addition to all arguments above, the following attributes are exported: | ||
|
|
||
| - `id` - The ID of the Instance group. | ||
| - `created_at` - Date and time of Instance group's creation (RFC 3339 format). | ||
| - `updated_at` - Date and time of Instance group's last update (RFC 3339 format). | ||
|
|
||
| ~> **Important:** Autoscaling Instance template IDs are [zonal](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111` | ||
|
|
||
| ## Import | ||
|
|
||
| Autoscaling Instance templates can be imported using `{zone}/{id}`, e.g. | ||
|
|
||
| ```bash | ||
| terraform import scaleway_autoscaling_instance_template.main fr-par-1/11111111-1111-1111-1111-111111111111 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.