Change worker managed instance group to span zones in region

* Change Google Cloud module to require the `region` variable
* Workers are created in random zones within the given region
* Tolerate Google Cloud zone failures or capacity issues
* If workers are preempted (if enabled), replacement instances can
be drawn from any zone in the region, which should avoid scheduling
issues that were possible before if a single zone aggressively
preempts instances (presumably due to Google Cloud capacity)
This commit is contained in:
Dalton Hubble
2017-11-04 10:57:12 -07:00
parent e32885c9cd
commit 6300383b43
8 changed files with 26 additions and 11 deletions

View File

@ -20,9 +20,9 @@ variable "count" {
description = "Number of worker compute instances the instance group should manage"
}
variable "zone" {
variable "region" {
type = "string"
description = "Google zone that compute instances in the group should be created in (e.g. gcloud compute zones list)"
description = "Google Cloud region to create a regional managed group of workers (e.g. us-central1, see `gcloud compute regions list`)."
}
variable "machine_type" {

View File

@ -1,16 +1,17 @@
# Managed Instance Group
resource "google_compute_instance_group_manager" "workers" {
# Regional managed instance group maintains a homogeneous set of workers that
# span the zones in the region.
resource "google_compute_region_instance_group_manager" "workers" {
name = "${var.cluster_name}-worker-group"
description = "Compute instance group of ${var.cluster_name} workers"
# Instance name prefix for instances in the group
# instance name prefix for instances in the group
base_instance_name = "${var.cluster_name}-worker"
instance_template = "${google_compute_instance_template.worker.self_link}"
update_strategy = "RESTART"
zone = "${var.zone}"
target_size = "${var.count}"
region = "${var.region}"
# Target pool instances in the group should be added into
target_size = "${var.count}"
# target pool to which instances in the group should be added
target_pools = [
"${google_compute_target_pool.workers.self_link}",
]