diff --git a/gcp-zonal/instances-web.tf b/gcp-zonal/instances-web.tf index b05fced..ce59a36 100644 --- a/gcp-zonal/instances-web.tf +++ b/gcp-zonal/instances-web.tf @@ -9,6 +9,12 @@ resource "google_compute_region_instance_group_manager" "web" { version { instance_template = google_compute_instance_template.web["all"].id } + update_policy { + type = "OPPORTUNISTIC" + instance_redistribution_type = "PROACTIVE" + minimal_action = "REPLACE" + replacement_method = "SUBSTITUTE" + } target_pools = [] target_size = lookup(var.instances["all"], "web_count", 0) @@ -39,6 +45,12 @@ resource "google_compute_instance_group_manager" "web" { version { instance_template = google_compute_instance_template.web[each.key].id } + update_policy { + type = "OPPORTUNISTIC" + minimal_action = "REPLACE" + max_unavailable_fixed = 1 + replacement_method = "SUBSTITUTE" + } named_port { name = "http" @@ -71,11 +83,13 @@ resource "google_compute_instance_template" "web" { label = "web" } - metadata_startup_script = templatefile("${path.module}/templates/worker.yaml.tpl", - merge(var.kubernetes, { - lbv4 = google_compute_address.lbv4_local.address - }) - ) + metadata = { + user-data = templatefile("${path.module}/templates/worker.yaml.tpl", + merge(var.kubernetes, { + lbv4 = google_compute_address.lbv4_local.address + }) + ) + } disk { boot = true diff --git a/gcp-zonal/instances-workers.tf b/gcp-zonal/instances-workers.tf index 4c5c866..7b483ab 100644 --- a/gcp-zonal/instances-workers.tf +++ b/gcp-zonal/instances-workers.tf @@ -9,6 +9,12 @@ resource "google_compute_region_instance_group_manager" "worker" { version { instance_template = google_compute_instance_template.worker["all"].id } + update_policy { + type = "OPPORTUNISTIC" + instance_redistribution_type = "PROACTIVE" + minimal_action = "REPLACE" + replacement_method = "SUBSTITUTE" + } target_pools = [] target_size = lookup(var.instances["all"], "worker_count", 0) @@ -30,6 +36,12 @@ resource "google_compute_instance_group_manager" "worker" { version { instance_template = google_compute_instance_template.worker[each.key].id } + update_policy { + type = "OPPORTUNISTIC" + minimal_action = "REPLACE" + max_unavailable_fixed = 1 + replacement_method = "SUBSTITUTE" + } target_pools = [] target_size = lookup(each.value, "worker_count", 0) @@ -53,11 +65,13 @@ resource "google_compute_instance_template" "worker" { label = "worker" } - metadata_startup_script = templatefile("${path.module}/templates/worker.yaml.tpl", - merge(var.kubernetes, { - lbv4 = google_compute_address.lbv4_local.address - }) - ) + metadata = { + user-data = templatefile("${path.module}/templates/worker.yaml.tpl", + merge(var.kubernetes, { + lbv4 = google_compute_address.lbv4_local.address + }) + ) + } disk { boot = true