Skip to content

Commit 2bdb88d

Browse files
committed
Add autoscale settings for non management clusters
1 parent 68ad896 commit 2bdb88d

File tree

3 files changed

+227
-1
lines changed

3 files changed

+227
-1
lines changed

mmv1/products/vmwareengine/Cluster.yaml

+116
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,119 @@ 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 there 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: 'minNodeCount'
190+
type: Integer
191+
description: |
192+
Minimum number of nodes of the given type in a cluster.
193+
The number is coerced to the minimum number of nodes of any type in the cluster.
194+
- name: 'maxNodeCount'
195+
type: Integer
196+
description: |
197+
Maximum number of nodes of the given type in a cluster.
198+
The number is coerced to the maximum number of nodes of any type in the cluster.
199+
- name: 'cpuThresholds'
200+
type: NestedObject
201+
description: |
202+
Utilization thresholds pertaining to CPU utilization.
203+
properties:
204+
- name: 'scaleOut'
205+
type: Integer
206+
description: |
207+
The utilization triggering the scale-out operation in percent.
208+
- name: 'scaleIn'
209+
type: Integer
210+
description: |
211+
The utilization triggering the scale-in operation in percent.
212+
- name: 'grantedMemoryThresholds'
213+
type: NestedObject
214+
description: |
215+
Utilization thresholds pertaining to amount of granted memory.
216+
properties:
217+
- name: 'scaleOut'
218+
type: Integer
219+
description: |
220+
The utilization triggering the scale-out operation in percent.
221+
- name: 'scaleIn'
222+
type: Integer
223+
description: |
224+
The utilization triggering the scale-in operation in percent.
225+
- name: 'consumedMemoryThresholds'
226+
type: NestedObject
227+
description: |
228+
Utilization thresholds pertaining to amount of consumed memory.
229+
properties:
230+
- name: 'scaleOut'
231+
type: Integer
232+
description: |
233+
The utilization triggering the scale-out operation in percent.
234+
- name: 'scaleIn'
235+
type: Integer
236+
description: |
237+
The utilization triggering the scale-in operation in percent.
238+
- name: 'storageThresholds'
239+
type: NestedObject
240+
description: |
241+
Utilization thresholds pertaining to amount of consumed storage.
242+
properties:
243+
- name: 'scaleOut'
244+
type: Integer
245+
description: |
246+
The utilization triggering the scale-out operation in percent.
247+
- name: 'scaleIn'
248+
type: Integer
249+
description: |
250+
The utilization triggering the scale-in operation in percent.
251+
- name: 'minClusterNodeCount'
252+
type: Integer
253+
description: |
254+
Minimum number of nodes of any type in a cluster.
255+
If not specified the default limits apply.
256+
- name: 'maxClusterNodeCount'
257+
type: Integer
258+
description: |
259+
Maximum number of nodes of any type in a cluster.
260+
If not specified the default limits apply.
261+
- name: 'coolDownPeriod'
262+
type: String
263+
description: |
264+
The minimum duration between consecutive autoscale operations.
265+
It starts once addition or removal of nodes is fully completed.
266+
Defaults to 30m if not specified.
267+
Cool down period must be in whole minutes (for example, 30m, 31m, 50m).

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

+24
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ resource "google_vmwareengine_private_cloud" "cluster-pc" {
2424
node_count = 3
2525
custom_core_count = 32
2626
}
27+
autoscaling_settings {
28+
autoscaling_policies {
29+
autoscale_policy_id = "autoscaling-policy"
30+
node_type_id = "standard-72"
31+
scale_out_size = 1
32+
min_node_count = 3
33+
max_node_count = 8
34+
cpu_thresholds {
35+
scale_out = 75
36+
scale_in = 15
37+
}
38+
consumed_memory_thresholds {
39+
scale_out = 85
40+
scale_in = 10
41+
}
42+
storage_thresholds {
43+
scale_out = 79
44+
scale_in = 20
45+
}
46+
}
47+
min_cluster_node_count = 3
48+
max_cluster_node_count = 8
49+
cool_down_period = "1800s"
50+
}
2751
}
2852
}
2953

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

+87-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,92 @@ 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+
min_node_count = 3
113+
max_node_count = 8
114+
storage_thresholds {
115+
scale_out = 80
116+
scale_in = 20
117+
}
118+
}
119+
min_cluster_node_count = 3
120+
max_cluster_node_count = 8
121+
cool_down_period = "1800s"
122+
}
123+
}
124+
125+
data "google_vmwareengine_cluster" "ds" {
126+
name = google_vmwareengine_cluster.vmw-engine-ext-cluster.name
127+
parent = google_vmwareengine_private_cloud.cluster-pc.id
128+
}
129+
`, context)
130+
}
131+
132+
func testVmwareEngineClusterConfigWithAutoscaleSettings(context map[string]interface{}, nodeCount int) string {
133+
context["node_count"] = nodeCount
134+
return acctest.Nprintf(`
135+
resource "google_vmwareengine_network" "cluster-nw" {
136+
name = "tf-test-cluster-nw%{random_suffix}"
137+
location = "global"
138+
type = "STANDARD"
139+
description = "PC network description."
140+
}
141+
142+
resource "google_vmwareengine_private_cloud" "cluster-pc" {
143+
location = "%{region}-b"
144+
name = "tf-test-cluster-pc%{random_suffix}"
145+
description = "Sample test PC."
146+
deletion_delay_hours = 0
147+
send_deletion_delay_hours_if_zero = true
148+
network_config {
149+
management_cidr = "192.168.10.0/24"
150+
vmware_engine_network = google_vmwareengine_network.cluster-nw.id
151+
}
152+
management_cluster {
153+
cluster_id = "tf-test-mgmt-cluster%{random_suffix}"
154+
node_type_configs {
155+
node_type_id = "standard-72"
156+
node_count = 3
157+
}
158+
}
159+
}
160+
161+
resource "google_vmwareengine_cluster" "vmw-engine-ext-cluster" {
162+
name = "tf-test-ext-cluster%{random_suffix}"
163+
parent = google_vmwareengine_private_cloud.cluster-pc.id
164+
node_type_configs {
165+
node_type_id = "standard-72"
166+
node_count = %{node_count}
167+
custom_core_count = 32
168+
}
169+
autoscaling_settings {
170+
autoscaling_policies {
171+
autoscale_policy_id = "autoscaling-policy"
172+
node_type_id = "standard-72"
173+
scale_out_size = 2
174+
min_node_count = 3
175+
max_node_count = 10
176+
cpu_thresholds {
177+
scale_out = 75
178+
scale_in = 15
179+
}
180+
consumed_memory_thresholds {
181+
scale_out = 85
182+
scale_in = 10
183+
}
184+
storage_thresholds {
185+
scale_out = 79
186+
scale_in = 20
187+
}
188+
}
189+
min_cluster_node_count = 3
190+
max_cluster_node_count = 10
191+
cool_down_period = "3600s"
192+
}
107193
}
108194
109195
data "google_vmwareengine_cluster" "ds" {

0 commit comments

Comments
 (0)