Skip to content

Commit 0e885d3

Browse files
varshatumburuBBBmau
authored andcommitted
Add autoscaling settings to external clusters (GoogleCloudPlatform#12003)
1 parent a5d6125 commit 0e885d3

File tree

3 files changed

+205
-2
lines changed

3 files changed

+205
-2
lines changed

mmv1/products/vmwareengine/Cluster.yaml

+100
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,103 @@ properties:
149149
If zero is provided max value from `nodeType.availableCustomCoreCounts` will be used.
150150
Once the customer is created then corecount cannot be changed.
151151
default_value: 0
152+
- name: 'autoscalingSettings'
153+
type: NestedObject
154+
description: |
155+
Configuration of the autoscaling applied to this cluster
156+
properties:
157+
- name: 'autoscalingPolicies'
158+
type: Map
159+
required: true
160+
description: |
161+
The map with autoscaling policies applied to the cluster.
162+
The key is the identifier of the policy.
163+
It must meet the following requirements:
164+
* Only contains 1-63 alphanumeric characters and hyphens
165+
* Begins with an alphabetical character
166+
* Ends with a non-hyphen character
167+
* Not formatted as a UUID
168+
* Complies with [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034) (section 3.5)
169+
170+
Currently the map must contain only one element
171+
that describes the autoscaling policy for compute nodes.
172+
key_name: 'autoscale_policy_id'
173+
key_description: 'The key is the identifier of the policy.'
174+
value_type:
175+
name: AutoscalingPolicy
176+
type: NestedObject
177+
properties:
178+
- name: 'nodeTypeId'
179+
type: String
180+
required: true
181+
description: |
182+
The canonical identifier of the node type to add or remove.
183+
- name: 'scaleOutSize'
184+
type: Integer
185+
required: true
186+
description: |
187+
Number of nodes to add to a cluster during a scale-out operation.
188+
Must be divisible by 2 for stretched clusters.
189+
- name: 'cpuThresholds'
190+
type: NestedObject
191+
description: |
192+
Utilization thresholds pertaining to CPU utilization.
193+
properties:
194+
- name: 'scaleOut'
195+
type: Integer
196+
required: true
197+
description: |
198+
The utilization triggering the scale-out operation in percent.
199+
- name: 'scaleIn'
200+
type: Integer
201+
required: true
202+
description: |
203+
The utilization triggering the scale-in operation in percent.
204+
- name: 'consumedMemoryThresholds'
205+
type: NestedObject
206+
description: |
207+
Utilization thresholds pertaining to amount of consumed memory.
208+
properties:
209+
- name: 'scaleOut'
210+
type: Integer
211+
required: true
212+
description: |
213+
The utilization triggering the scale-out operation in percent.
214+
- name: 'scaleIn'
215+
type: Integer
216+
required: true
217+
description: |
218+
The utilization triggering the scale-in operation in percent.
219+
- name: 'storageThresholds'
220+
type: NestedObject
221+
description: |
222+
Utilization thresholds pertaining to amount of consumed storage.
223+
properties:
224+
- name: 'scaleOut'
225+
type: Integer
226+
required: true
227+
description: |
228+
The utilization triggering the scale-out operation in percent.
229+
- name: 'scaleIn'
230+
type: Integer
231+
required: true
232+
description: |
233+
The utilization triggering the scale-in operation in percent.
234+
- name: 'minClusterNodeCount'
235+
type: Integer
236+
description: |
237+
Minimum number of nodes of any type in a cluster.
238+
Mandatory for successful addition of autoscaling settings in cluster.
239+
- name: 'maxClusterNodeCount'
240+
type: Integer
241+
description: |
242+
Maximum number of nodes of any type in a cluster.
243+
Mandatory for successful addition of autoscaling settings in cluster.
244+
- name: 'coolDownPeriod'
245+
type: String
246+
description: |
247+
The minimum duration between consecutive autoscale operations.
248+
It starts once addition or removal of nodes is fully completed.
249+
Minimum cool down period is 30m.
250+
Cool down period must be in whole minutes (for example, 30m, 31m, 50m).
251+
Mandatory for successful addition of autoscaling settings in cluster.

mmv1/templates/terraform/examples/vmware_engine_cluster_full.tf.tmpl

+22-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ resource "google_vmwareengine_cluster" "{{$.PrimaryResourceId}}" {
66
node_count = 3
77
custom_core_count = 32
88
}
9+
autoscaling_settings {
10+
autoscaling_policies {
11+
autoscale_policy_id = "autoscaling-policy"
12+
node_type_id = "standard-72"
13+
scale_out_size = 1
14+
cpu_thresholds {
15+
scale_out = 80
16+
scale_in = 15
17+
}
18+
consumed_memory_thresholds {
19+
scale_out = 75
20+
scale_in = 20
21+
}
22+
storage_thresholds {
23+
scale_out = 80
24+
scale_in = 20
25+
}
26+
}
27+
min_cluster_node_count = 3
28+
max_cluster_node_count = 8
29+
cool_down_period = "1800s"
30+
}
931
}
1032

1133
resource "google_vmwareengine_private_cloud" "cluster-pc" {
@@ -16,7 +38,6 @@ resource "google_vmwareengine_private_cloud" "cluster-pc" {
1638
management_cidr = "192.168.30.0/24"
1739
vmware_engine_network = google_vmwareengine_network.cluster-nw.id
1840
}
19-
2041
management_cluster {
2142
cluster_id = "{{index $.Vars "management_cluster_id"}}"
2243
node_type_configs {

mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_cluster_test.go

+83-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestAccVmwareengineCluster_vmwareEngineClusterUpdate(t *testing.T) {
4646
ImportStateVerifyIgnore: []string{"parent", "name"},
4747
},
4848
{
49-
Config: testVmwareEngineClusterConfig(context, 4), // expand the cluster
49+
Config: testVmwareEngineClusterUpdateConfig(context, 4), // expand the cluster
5050
},
5151
{
5252
ResourceName: "google_vmwareengine_cluster.vmw-engine-ext-cluster",
@@ -104,6 +104,88 @@ resource "google_vmwareengine_cluster" "vmw-engine-ext-cluster" {
104104
node_count = %{node_count}
105105
custom_core_count = 32
106106
}
107+
autoscaling_settings {
108+
autoscaling_policies {
109+
autoscale_policy_id = "autoscaling-policy"
110+
node_type_id = "standard-72"
111+
scale_out_size = 1
112+
consumed_memory_thresholds {
113+
scale_out = 75
114+
scale_in = 20
115+
}
116+
storage_thresholds {
117+
scale_out = 80
118+
scale_in = 20
119+
}
120+
}
121+
min_cluster_node_count = 3
122+
max_cluster_node_count = 8
123+
cool_down_period = "1800s"
124+
}
125+
}
126+
127+
data "google_vmwareengine_cluster" "ds" {
128+
name = google_vmwareengine_cluster.vmw-engine-ext-cluster.name
129+
parent = google_vmwareengine_private_cloud.cluster-pc.id
130+
}
131+
`, context)
132+
}
133+
134+
func testVmwareEngineClusterUpdateConfig(context map[string]interface{}, nodeCount int) string {
135+
context["node_count"] = nodeCount
136+
return acctest.Nprintf(`
137+
resource "google_vmwareengine_network" "cluster-nw" {
138+
name = "tf-test-cluster-nw%{random_suffix}"
139+
location = "global"
140+
type = "STANDARD"
141+
description = "PC network description."
142+
}
143+
144+
resource "google_vmwareengine_private_cloud" "cluster-pc" {
145+
location = "%{region}-b"
146+
name = "tf-test-cluster-pc%{random_suffix}"
147+
description = "Sample test PC."
148+
deletion_delay_hours = 0
149+
send_deletion_delay_hours_if_zero = true
150+
network_config {
151+
management_cidr = "192.168.10.0/24"
152+
vmware_engine_network = google_vmwareengine_network.cluster-nw.id
153+
}
154+
management_cluster {
155+
cluster_id = "tf-test-mgmt-cluster%{random_suffix}"
156+
node_type_configs {
157+
node_type_id = "standard-72"
158+
node_count = 3
159+
}
160+
}
161+
}
162+
163+
resource "google_vmwareengine_cluster" "vmw-engine-ext-cluster" {
164+
name = "tf-test-ext-cluster%{random_suffix}"
165+
parent = google_vmwareengine_private_cloud.cluster-pc.id
166+
node_type_configs {
167+
node_type_id = "standard-72"
168+
node_count = %{node_count}
169+
custom_core_count = 32
170+
}
171+
autoscaling_settings {
172+
autoscaling_policies {
173+
autoscale_policy_id = "autoscaling-policy"
174+
node_type_id = "standard-72"
175+
scale_out_size = 2
176+
cpu_thresholds {
177+
scale_out = 80
178+
scale_in = 15
179+
}
180+
storage_thresholds {
181+
scale_out = 79
182+
scale_in = 15
183+
}
184+
}
185+
min_cluster_node_count = 3
186+
max_cluster_node_count = 10
187+
cool_down_period = "3600s"
188+
}
107189
}
108190
109191
data "google_vmwareengine_cluster" "ds" {

0 commit comments

Comments
 (0)