Skip to content

Commit

Permalink
Add node group autoscaling policy (#3230)
Browse files Browse the repository at this point in the history
* Add node group autoscaling policy

* add default_from_api

* Update api.yaml
  • Loading branch information
c2thorn authored Mar 9, 2020
1 parent aeb7b24 commit b366344
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
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. Must be less
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
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
}
}

0 comments on commit b366344

Please sign in to comment.