terraform/gcp: Allow to use preemptible VM instances (#8480)

This commit is contained in:
Mathieu Parent
2022-01-31 09:30:24 +01:00
committed by GitHub
parent ababcd5481
commit 3562d3378b
5 changed files with 38 additions and 4 deletions

View File

@@ -231,6 +231,11 @@ resource "google_compute_instance" "master" {
lifecycle {
ignore_changes = [attached_disk]
}
scheduling {
preemptible = var.master_preemptible
automatic_restart = !var.master_preemptible
}
}
resource "google_compute_forwarding_rule" "master_lb" {
@@ -328,6 +333,11 @@ resource "google_compute_instance" "worker" {
lifecycle {
ignore_changes = [attached_disk]
}
scheduling {
preemptible = var.worker_preemptible
automatic_restart = !var.worker_preemptible
}
}
resource "google_compute_address" "worker_lb" {

View File

@@ -27,6 +27,10 @@ variable "master_sa_scopes" {
type = list(string)
}
variable "master_preemptible" {
type = bool
}
variable "worker_sa_email" {
type = string
}
@@ -35,6 +39,10 @@ variable "worker_sa_scopes" {
type = list(string)
}
variable "worker_preemptible" {
type = bool
}
variable "ssh_pub_key" {}
variable "ssh_whitelist" {