Skip to content

Commit

Permalink
Add autoscaling settings to external clusters (GoogleCloudPlatform#12003
Browse files Browse the repository at this point in the history
)
  • Loading branch information
varshatumburu authored and akshat-jindal-nit committed Nov 18, 2024
1 parent 236091d commit ded4ec2
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 2 deletions.
100 changes: 100 additions & 0 deletions mmv1/products/vmwareengine/Cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,103 @@ properties:
If zero is provided max value from `nodeType.availableCustomCoreCounts` will be used.
Once the customer is created then corecount cannot be changed.
default_value: 0
- name: 'autoscalingSettings'
type: NestedObject
description: |
Configuration of the autoscaling applied to this cluster
properties:
- name: 'autoscalingPolicies'
type: Map
required: true
description: |
The map with autoscaling policies applied to the cluster.
The key is the identifier of the policy.
It must meet the following requirements:
* Only contains 1-63 alphanumeric characters and hyphens
* Begins with an alphabetical character
* Ends with a non-hyphen character
* Not formatted as a UUID
* Complies with [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034) (section 3.5)
Currently the map must contain only one element
that describes the autoscaling policy for compute nodes.
key_name: 'autoscale_policy_id'
key_description: 'The key is the identifier of the policy.'
value_type:
name: AutoscalingPolicy
type: NestedObject
properties:
- name: 'nodeTypeId'
type: String
required: true
description: |
The canonical identifier of the node type to add or remove.
- name: 'scaleOutSize'
type: Integer
required: true
description: |
Number of nodes to add to a cluster during a scale-out operation.
Must be divisible by 2 for stretched clusters.
- name: 'cpuThresholds'
type: NestedObject
description: |
Utilization thresholds pertaining to CPU utilization.
properties:
- name: 'scaleOut'
type: Integer
required: true
description: |
The utilization triggering the scale-out operation in percent.
- name: 'scaleIn'
type: Integer
required: true
description: |
The utilization triggering the scale-in operation in percent.
- name: 'consumedMemoryThresholds'
type: NestedObject
description: |
Utilization thresholds pertaining to amount of consumed memory.
properties:
- name: 'scaleOut'
type: Integer
required: true
description: |
The utilization triggering the scale-out operation in percent.
- name: 'scaleIn'
type: Integer
required: true
description: |
The utilization triggering the scale-in operation in percent.
- name: 'storageThresholds'
type: NestedObject
description: |
Utilization thresholds pertaining to amount of consumed storage.
properties:
- name: 'scaleOut'
type: Integer
required: true
description: |
The utilization triggering the scale-out operation in percent.
- name: 'scaleIn'
type: Integer
required: true
description: |
The utilization triggering the scale-in operation in percent.
- name: 'minClusterNodeCount'
type: Integer
description: |
Minimum number of nodes of any type in a cluster.
Mandatory for successful addition of autoscaling settings in cluster.
- name: 'maxClusterNodeCount'
type: Integer
description: |
Maximum number of nodes of any type in a cluster.
Mandatory for successful addition of autoscaling settings in cluster.
- name: 'coolDownPeriod'
type: String
description: |
The minimum duration between consecutive autoscale operations.
It starts once addition or removal of nodes is fully completed.
Minimum cool down period is 30m.
Cool down period must be in whole minutes (for example, 30m, 31m, 50m).
Mandatory for successful addition of autoscaling settings in cluster.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ resource "google_vmwareengine_cluster" "{{$.PrimaryResourceId}}" {
node_count = 3
custom_core_count = 32
}
autoscaling_settings {
autoscaling_policies {
autoscale_policy_id = "autoscaling-policy"
node_type_id = "standard-72"
scale_out_size = 1
cpu_thresholds {
scale_out = 80
scale_in = 15
}
consumed_memory_thresholds {
scale_out = 75
scale_in = 20
}
storage_thresholds {
scale_out = 80
scale_in = 20
}
}
min_cluster_node_count = 3
max_cluster_node_count = 8
cool_down_period = "1800s"
}
}

resource "google_vmwareengine_private_cloud" "cluster-pc" {
Expand All @@ -16,7 +38,6 @@ resource "google_vmwareengine_private_cloud" "cluster-pc" {
management_cidr = "192.168.30.0/24"
vmware_engine_network = google_vmwareengine_network.cluster-nw.id
}

management_cluster {
cluster_id = "{{index $.Vars "management_cluster_id"}}"
node_type_configs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestAccVmwareengineCluster_vmwareEngineClusterUpdate(t *testing.T) {
ImportStateVerifyIgnore: []string{"parent", "name"},
},
{
Config: testVmwareEngineClusterConfig(context, 4), // expand the cluster
Config: testVmwareEngineClusterUpdateConfig(context, 4), // expand the cluster
},
{
ResourceName: "google_vmwareengine_cluster.vmw-engine-ext-cluster",
Expand Down Expand Up @@ -104,6 +104,88 @@ resource "google_vmwareengine_cluster" "vmw-engine-ext-cluster" {
node_count = %{node_count}
custom_core_count = 32
}
autoscaling_settings {
autoscaling_policies {
autoscale_policy_id = "autoscaling-policy"
node_type_id = "standard-72"
scale_out_size = 1
consumed_memory_thresholds {
scale_out = 75
scale_in = 20
}
storage_thresholds {
scale_out = 80
scale_in = 20
}
}
min_cluster_node_count = 3
max_cluster_node_count = 8
cool_down_period = "1800s"
}
}
data "google_vmwareengine_cluster" "ds" {
name = google_vmwareengine_cluster.vmw-engine-ext-cluster.name
parent = google_vmwareengine_private_cloud.cluster-pc.id
}
`, context)
}

func testVmwareEngineClusterUpdateConfig(context map[string]interface{}, nodeCount int) string {
context["node_count"] = nodeCount
return acctest.Nprintf(`
resource "google_vmwareengine_network" "cluster-nw" {
name = "tf-test-cluster-nw%{random_suffix}"
location = "global"
type = "STANDARD"
description = "PC network description."
}
resource "google_vmwareengine_private_cloud" "cluster-pc" {
location = "%{region}-b"
name = "tf-test-cluster-pc%{random_suffix}"
description = "Sample test PC."
deletion_delay_hours = 0
send_deletion_delay_hours_if_zero = true
network_config {
management_cidr = "192.168.10.0/24"
vmware_engine_network = google_vmwareengine_network.cluster-nw.id
}
management_cluster {
cluster_id = "tf-test-mgmt-cluster%{random_suffix}"
node_type_configs {
node_type_id = "standard-72"
node_count = 3
}
}
}
resource "google_vmwareengine_cluster" "vmw-engine-ext-cluster" {
name = "tf-test-ext-cluster%{random_suffix}"
parent = google_vmwareengine_private_cloud.cluster-pc.id
node_type_configs {
node_type_id = "standard-72"
node_count = %{node_count}
custom_core_count = 32
}
autoscaling_settings {
autoscaling_policies {
autoscale_policy_id = "autoscaling-policy"
node_type_id = "standard-72"
scale_out_size = 2
cpu_thresholds {
scale_out = 80
scale_in = 15
}
storage_thresholds {
scale_out = 79
scale_in = 15
}
}
min_cluster_node_count = 3
max_cluster_node_count = 10
cool_down_period = "3600s"
}
}
data "google_vmwareengine_cluster" "ds" {
Expand Down

0 comments on commit ded4ec2

Please sign in to comment.