Skip to content
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

Add node group autoscaling policy #3230

Merged
merged 3 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7358,6 +7358,38 @@ objects:
The total number of nodes in the node group.
required: true
send_empty_value: true
- !ruby/object:Api::Type::NestedObject
name: 'autoscalingPolicy'
min_version: beta
description: |
If you use sole-tenant nodes for your workloads, you can use the node
group autoscaler to automatically manage the sizes of your node groups.
properties:
- !ruby/object:Api::Type::Enum
name: 'mode'
required: true
description: |
The autoscaling mode. Set to one of the following:
- OFF: Disables the autoscaler.
- ON: Enables scaling in and scaling out.
- ONLY_SCALE_OUT: Enables only scaling out.
You must use this mode if your node groups are configured to
restart their hosted VMs on minimal servers.
values:
- :OFF
- :ON
- :ONLY_SCALE_OUT
- !ruby/object:Api::Type::Integer
name: 'minNodes'
description: |
Minimum size of the node group, and must be an integer value less
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little awkwardly worded. Maybe "Minimum size of the node group. Must be an ..."

than or equal to max-nodes. The default value is 0.
- !ruby/object:Api::Type::Integer
name: 'maxNodes'
description: |
Maximum size of the node group. Set to a value less than or equal
to 100 and greater than or equal to min-nodes.
required: true
- !ruby/object:Api::Resource
name: 'NetworkPeeringRoutesConfig'
base_url: 'projects/{{project}}/global/networks/{{network}}'
Expand Down
15 changes: 15 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1119,11 +1119,26 @@ overrides: !ruby/object:Overrides::ResourceOverrides
vars:
group_name: "soletenant-group"
template_name: "soletenant-tmpl"
- !ruby/object:Provider::Terraform::Examples
name: "node_group_autoscaling_policy"
min_version: beta
primary_resource_id: "nodes"
vars:
group_name: "soletenant-group"
template_name: "soletenant-tmpl"
properties:
zone: !ruby/object:Overrides::Terraform::PropertyOverride
required: false
default_from_api: true
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
autoscalingPolicy: !ruby/object:Overrides::Terraform::PropertyOverride
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to all be O+C? Is the autoscalingPolicy block returned from the API even if it is undefined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the block was returning from the API in the basic test without autoscalingPolicy being set in the config, and was throwing a diff.

If the block IS defined, mode and maxNodes are required.

default_from_api: true
autoscalingPolicy.mode: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
autoscalingPolicy.minNodes: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
autoscalingPolicy.maxNodes: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
NodeTemplate: !ruby/object:Overrides::Terraform::ResourceOverride
examples:
- !ruby/object:Provider::Terraform::Examples
Expand Down
26 changes: 26 additions & 0 deletions templates/terraform/examples/node_group_autoscaling_policy.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
data "google_compute_node_types" "central1a" {
provider = google-beta
zone = "us-central1-a"
}

resource "google_compute_node_template" "soletenant-tmpl" {
provider = google-beta
name = "<%= ctx[:vars]['template_name'] %>"
region = "us-central1"
node_type = data.google_compute_node_types.central1a.names[0]
}

resource "google_compute_node_group" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]['group_name'] %>"
zone = "us-central1-a"
description = "example google_compute_node_group for Terraform Google Provider"

size = 1
node_template = google_compute_node_template.soletenant-tmpl.self_link
autoscaling_policy {
mode = "ON"
min_nodes = 1
max_nodes = 10
}
}