-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: autoscaler supporting stateful ips (#297)
- Loading branch information
Showing
24 changed files
with
479 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# mig-simple | ||
|
||
This is a simple, minimal example of how to use the MIG module to create a | ||
managed instance group. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| project\_id | The GCP project to use for integration tests | `string` | n/a | yes | | ||
| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | | ||
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. | <pre>object({<br> email = string<br> scopes = set(string)<br> })</pre> | `null` | no | | ||
| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | | ||
| target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | `any` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| region | The GCP region to create and test resources in | | ||
| self\_link | Self-link of the managed instance group | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
provider "google" { | ||
} | ||
|
||
provider "google-beta" { | ||
} | ||
|
||
resource "random_string" "suffix" { | ||
length = 4 | ||
special = "false" | ||
upper = "false" | ||
} | ||
|
||
/** Network **/ | ||
|
||
resource "google_compute_network" "main" { | ||
project = var.project_id | ||
name = "cft-vm-test-${random_string.suffix.result}" | ||
auto_create_subnetworks = "false" | ||
} | ||
|
||
resource "google_compute_subnetwork" "main" { | ||
project = var.project_id | ||
region = var.region | ||
name = "cft-vm-test-${random_string.suffix.result}" | ||
ip_cidr_range = "10.128.0.0/20" | ||
network = google_compute_network.main.self_link | ||
} | ||
|
||
module "instance_template" { | ||
source = "../../modules/instance_template" | ||
project_id = var.project_id | ||
region = var.region | ||
subnetwork = var.subnetwork | ||
service_account = var.service_account | ||
subnetwork_project = var.project_id | ||
} | ||
|
||
module "mig" { | ||
source = "../../modules/mig" | ||
project_id = var.project_id | ||
region = var.region | ||
target_size = var.target_size | ||
hostname = "mig-stateful" | ||
instance_template = module.instance_template.self_link | ||
stateful_ips = [{ | ||
interface_name = "nic0" | ||
delete_rule = "ON_PERMANENT_INSTANCE_DELETION" | ||
is_external = true | ||
}] | ||
|
||
update_policy = [{ | ||
max_surge_fixed = 0 | ||
instance_redistribution_type = "NONE" | ||
max_surge_percent = null | ||
max_unavailable_fixed = 4 | ||
max_unavailable_percent = null | ||
min_ready_sec = 180 | ||
replacement_method = "RECREATE" | ||
minimal_action = "REFRESH" | ||
type = "OPPORTUNISTIC" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "self_link" { | ||
description = "Self-link of the managed instance group" | ||
value = module.mig.self_link | ||
} | ||
|
||
output "region" { | ||
description = "The GCP region to create and test resources in" | ||
value = var.region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
|
||
variable "project_id" { | ||
description = "The GCP project to use for integration tests" | ||
type = string | ||
} | ||
|
||
variable "region" { | ||
description = "The GCP region to create and test resources in" | ||
type = string | ||
default = "us-central1" | ||
} | ||
|
||
variable "subnetwork" { | ||
description = "The subnetwork to host the compute instances in" | ||
} | ||
|
||
variable "target_size" { | ||
description = "The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set." | ||
} | ||
|
||
variable "service_account" { | ||
default = null | ||
type = object({ | ||
email = string | ||
scopes = set(string) | ||
}) | ||
description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 4.0" | ||
} | ||
google-beta = { | ||
source = "hashicorp/google-beta" | ||
version = "~> 4.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.