Browse Source

terraform/gcp: Allow to change extra disk types (#8524)

pull/8545/head
Mathieu Parent 2 years ago
committed by GitHub
parent
commit
31d4a38f09
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 5 deletions
  1. 10
      contrib/terraform/gcp/README.md
  2. 2
      contrib/terraform/gcp/main.tf
  3. 4
      contrib/terraform/gcp/modules/kubernetes-cluster/main.tf
  4. 8
      contrib/terraform/gcp/modules/kubernetes-cluster/variables.tf
  5. 10
      contrib/terraform/gcp/variables.tf

10
contrib/terraform/gcp/README.md

@ -78,14 +78,18 @@ ansible-playbook -i contrib/terraform/gcs/inventory.ini cluster.yml -b -v
### Optional ### Optional
* `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_scopes`: Service account email to use for the master nodes *(Defaults to `["https://www.googleapis.com/auth/cloud-platform"]`)*
* `master_sa_email`: Service account email to use for the control plane nodes *(Defaults to `""`, auto generate one)*
* `master_sa_scopes`: Service account email to use for the control plane nodes *(Defaults to `["https://www.googleapis.com/auth/cloud-platform"]`)*
* `master_preemptible`: Enable [preemptible](https://cloud.google.com/compute/docs/instances/preemptible) * `master_preemptible`: Enable [preemptible](https://cloud.google.com/compute/docs/instances/preemptible)
for the master nodes *(Defaults to `false`)*
for the control plane nodes *(Defaults to `false`)*
* `master_additional_disk_type`: [Disk type](https://cloud.google.com/compute/docs/disks/#disk-types)
for extra disks added on the control plane nodes *(Defaults to `"pd-ssd"`)*
* `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) * `worker_preemptible`: Enable [preemptible](https://cloud.google.com/compute/docs/instances/preemptible)
for the worker nodes *(Defaults to `false`)* for the worker nodes *(Defaults to `false`)*
* `worker_additional_disk_type`: [Disk type](https://cloud.google.com/compute/docs/disks/#disk-types)
for extra disks added on the worker nodes *(Defaults to `"pd-ssd"`)*
An example variables file can be found `tfvars.json` An example variables file can be found `tfvars.json`

2
contrib/terraform/gcp/main.tf

@ -24,9 +24,11 @@ module "kubernetes" {
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
master_preemptible = var.master_preemptible master_preemptible = var.master_preemptible
master_additional_disk_type = var.master_additional_disk_type
worker_sa_email = var.worker_sa_email worker_sa_email = var.worker_sa_email
worker_sa_scopes = var.worker_sa_scopes worker_sa_scopes = var.worker_sa_scopes
worker_preemptible = var.worker_preemptible worker_preemptible = var.worker_preemptible
worker_additional_disk_type = var.worker_additional_disk_type
ssh_whitelist = var.ssh_whitelist ssh_whitelist = var.ssh_whitelist
api_server_whitelist = var.api_server_whitelist api_server_whitelist = var.api_server_whitelist

4
contrib/terraform/gcp/modules/kubernetes-cluster/main.tf

@ -181,7 +181,7 @@ resource "google_compute_disk" "master" {
} }
name = "${var.prefix}-${each.key}" name = "${var.prefix}-${each.key}"
type = "pd-ssd"
type = var.master_additional_disk_type
zone = each.value.machine.zone zone = each.value.machine.zone
size = each.value.disk_size size = each.value.disk_size
@ -271,7 +271,7 @@ resource "google_compute_disk" "worker" {
} }
name = "${var.prefix}-${each.key}" name = "${var.prefix}-${each.key}"
type = "pd-ssd"
type = var.worker_additional_disk_type
zone = each.value.machine.zone zone = each.value.machine.zone
size = each.value.disk_size size = each.value.disk_size

8
contrib/terraform/gcp/modules/kubernetes-cluster/variables.tf

@ -31,6 +31,10 @@ variable "master_preemptible" {
type = bool type = bool
} }
variable "master_additional_disk_type" {
type = string
}
variable "worker_sa_email" { variable "worker_sa_email" {
type = string type = string
} }
@ -43,6 +47,10 @@ variable "worker_preemptible" {
type = bool type = bool
} }
variable "worker_additional_disk_type" {
type = string
}
variable "ssh_pub_key" {} variable "ssh_pub_key" {}
variable "ssh_whitelist" { variable "ssh_whitelist" {

10
contrib/terraform/gcp/variables.tf

@ -49,6 +49,11 @@ variable "master_preemptible" {
default = false default = false
} }
variable "master_additional_disk_type" {
type = string
default = "pd-ssd"
}
variable "worker_sa_email" { variable "worker_sa_email" {
type = string type = string
default = "" default = ""
@ -64,6 +69,11 @@ variable "worker_preemptible" {
default = false default = false
} }
variable "worker_additional_disk_type" {
type = string
default = "pd-ssd"
}
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…
Cancel
Save