terraform/gcp: Allow to use preemptible VM instances (#8480)
parent
ababcd5481
commit
3562d3378b
|
@ -80,8 +80,12 @@ ansible-playbook -i contrib/terraform/gcs/inventory.ini cluster.yml -b -v
|
||||||
* `prefix`: Prefix to use for all resources, required to be unique for all clusters in the same project *(Defaults to `default`)*
|
* `prefix`: Prefix to use for all resources, required to be unique for all clusters in the same project *(Defaults to `default`)*
|
||||||
* `master_sa_email`: Service account email to use for the master nodes *(Defaults to `""`, auto generate one)*
|
* `master_sa_email`: Service account email to use for the master nodes *(Defaults to `""`, auto generate one)*
|
||||||
* `master_sa_scopes`: Service account email to use for the master nodes *(Defaults to `["https://www.googleapis.com/auth/cloud-platform"]`)*
|
* `master_sa_scopes`: Service account email to use for the master nodes *(Defaults to `["https://www.googleapis.com/auth/cloud-platform"]`)*
|
||||||
|
* `master_preemptible`: Enable [preemptible](https://cloud.google.com/compute/docs/instances/preemptible)
|
||||||
|
for the master nodes *(Defaults to `false`)*
|
||||||
* `worker_sa_email`: Service account email to use for the worker nodes *(Defaults to `""`, auto generate one)*
|
* `worker_sa_email`: Service account email to use for the worker nodes *(Defaults to `""`, auto generate one)*
|
||||||
* `worker_sa_scopes`: Service account email to use for the worker nodes *(Defaults to `["https://www.googleapis.com/auth/cloud-platform"]`)*
|
* `worker_sa_scopes`: Service account email to use for the worker nodes *(Defaults to `["https://www.googleapis.com/auth/cloud-platform"]`)*
|
||||||
|
* `worker_preemptible`: Enable [preemptible](https://cloud.google.com/compute/docs/instances/preemptible)
|
||||||
|
for the worker nodes *(Defaults to `false`)*
|
||||||
|
|
||||||
An example variables file can be found `tfvars.json`
|
An example variables file can be found `tfvars.json`
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,12 @@ module "kubernetes" {
|
||||||
machines = var.machines
|
machines = var.machines
|
||||||
ssh_pub_key = var.ssh_pub_key
|
ssh_pub_key = var.ssh_pub_key
|
||||||
|
|
||||||
master_sa_email = var.master_sa_email
|
master_sa_email = var.master_sa_email
|
||||||
master_sa_scopes = var.master_sa_scopes
|
master_sa_scopes = var.master_sa_scopes
|
||||||
worker_sa_email = var.worker_sa_email
|
master_preemptible = var.master_preemptible
|
||||||
worker_sa_scopes = var.worker_sa_scopes
|
worker_sa_email = var.worker_sa_email
|
||||||
|
worker_sa_scopes = var.worker_sa_scopes
|
||||||
|
worker_preemptible = var.worker_preemptible
|
||||||
|
|
||||||
ssh_whitelist = var.ssh_whitelist
|
ssh_whitelist = var.ssh_whitelist
|
||||||
api_server_whitelist = var.api_server_whitelist
|
api_server_whitelist = var.api_server_whitelist
|
||||||
|
|
|
@ -231,6 +231,11 @@ resource "google_compute_instance" "master" {
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [attached_disk]
|
ignore_changes = [attached_disk]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduling {
|
||||||
|
preemptible = var.master_preemptible
|
||||||
|
automatic_restart = !var.master_preemptible
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_forwarding_rule" "master_lb" {
|
resource "google_compute_forwarding_rule" "master_lb" {
|
||||||
|
@ -328,6 +333,11 @@ resource "google_compute_instance" "worker" {
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [attached_disk]
|
ignore_changes = [attached_disk]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduling {
|
||||||
|
preemptible = var.worker_preemptible
|
||||||
|
automatic_restart = !var.worker_preemptible
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_address" "worker_lb" {
|
resource "google_compute_address" "worker_lb" {
|
||||||
|
|
|
@ -27,6 +27,10 @@ variable "master_sa_scopes" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "master_preemptible" {
|
||||||
|
type = bool
|
||||||
|
}
|
||||||
|
|
||||||
variable "worker_sa_email" {
|
variable "worker_sa_email" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
@ -35,6 +39,10 @@ variable "worker_sa_scopes" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "worker_preemptible" {
|
||||||
|
type = bool
|
||||||
|
}
|
||||||
|
|
||||||
variable "ssh_pub_key" {}
|
variable "ssh_pub_key" {}
|
||||||
|
|
||||||
variable "ssh_whitelist" {
|
variable "ssh_whitelist" {
|
||||||
|
|
|
@ -44,6 +44,11 @@ variable "master_sa_scopes" {
|
||||||
default = ["https://www.googleapis.com/auth/cloud-platform"]
|
default = ["https://www.googleapis.com/auth/cloud-platform"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "master_preemptible" {
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
variable "worker_sa_email" {
|
variable "worker_sa_email" {
|
||||||
type = string
|
type = string
|
||||||
default = ""
|
default = ""
|
||||||
|
@ -54,6 +59,11 @@ variable "worker_sa_scopes" {
|
||||||
default = ["https://www.googleapis.com/auth/cloud-platform"]
|
default = ["https://www.googleapis.com/auth/cloud-platform"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "worker_preemptible" {
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
variable ssh_pub_key {
|
variable ssh_pub_key {
|
||||||
description = "Path to public SSH key file which is injected into the VMs."
|
description = "Path to public SSH key file which is injected into the VMs."
|
||||||
type = string
|
type = string
|
||||||
|
|
Loading…
Reference in New Issue