terraform: allow for multiple instance groups (#1471)

This commit is contained in:
3u13r 2023-03-21 22:56:03 +01:00 committed by GitHub
parent 7a0cbe39f4
commit cf9970c051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 58 deletions

View File

@ -135,19 +135,20 @@ resource "google_compute_firewall" "firewall_internal_pods" {
}
module "instance_group_control_plane" {
source = "./modules/instance_group"
name = local.name
role = "ControlPlane"
uid = local.uid
instance_type = var.instance_type
instance_count = var.control_plane_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork.id
kube_env = local.kube_env
debug = var.debug
source = "./modules/instance_group"
name = local.name
role = "ControlPlane"
uid = local.uid
instance_type = var.instance_type
instance_count = var.control_plane_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork.id
alias_ip_range_name = google_compute_subnetwork.vpc_subnetwork.secondary_ip_range[0].range_name
kube_env = local.kube_env
debug = var.debug
named_ports = flatten([
{ name = "kubernetes", port = local.ports_kubernetes },
{ name = "bootstrapper", port = local.ports_bootstrapper },
@ -161,21 +162,22 @@ module "instance_group_control_plane" {
}
module "instance_group_worker" {
source = "./modules/instance_group"
name = local.name
role = "Worker"
uid = local.uid
instance_type = var.instance_type
instance_count = var.worker_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork.id
kube_env = local.kube_env
debug = var.debug
labels = local.labels
init_secret_hash = local.initSecretHash
source = "./modules/instance_group"
name = "${local.name}-1"
role = "Worker"
uid = local.uid
instance_type = var.instance_type
instance_count = var.worker_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork.id
alias_ip_range_name = google_compute_subnetwork.vpc_subnetwork.secondary_ip_range[0].range_name
kube_env = local.kube_env
debug = var.debug
labels = local.labels
init_secret_hash = local.initSecretHash
}
resource "google_compute_global_address" "loadbalancer_ip" {

View File

@ -52,7 +52,7 @@ resource "google_compute_instance_template" "template" {
subnetwork = var.subnetwork
alias_ip_range {
ip_cidr_range = "/24"
subnetwork_range_name = var.name
subnetwork_range_name = var.alias_ip_range_name
}
}

View File

@ -79,3 +79,8 @@ variable "debug" {
default = false
description = "Enable debug mode. This will enable serial port access on the instances."
}
variable "alias_ip_range_name" {
type = string
description = "Name of the alias IP range to use."
}

View File

@ -58,7 +58,9 @@ resource "random_password" "initSecret" {
resource "google_compute_network" "vpc_network" {
name = local.name
description = "Constellation VPC network"
auto_create_subnetworks = false
mtu = 8896
}
@ -151,19 +153,20 @@ resource "google_compute_firewall" "firewall_internal_pods" {
}
module "instance_group_control_plane" {
source = "./modules/instance_group"
name = local.name
role = "ControlPlane"
uid = local.uid
instance_type = var.instance_type
instance_count = var.control_plane_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork_backend.id
kube_env = local.kube_env
debug = var.debug
source = "./modules/instance_group"
name = local.name
role = "ControlPlane"
uid = local.uid
instance_type = var.instance_type
instance_count = var.control_plane_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork_backend.id
alias_ip_range_name = google_compute_subnetwork.vpc_subnetwork.secondary_ip_range[0].range_name
kube_env = local.kube_env
debug = var.debug
named_ports = flatten([
{ name = "kubernetes", port = local.ports_kubernetes },
{ name = "bootstrapper", port = local.ports_bootstrapper },
@ -177,21 +180,22 @@ module "instance_group_control_plane" {
}
module "instance_group_worker" {
source = "./modules/instance_group"
name = local.name
role = "Worker"
uid = local.uid
instance_type = var.instance_type
instance_count = var.worker_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork_backend.id
kube_env = local.kube_env
debug = var.debug
labels = local.labels
init_secret_hash = local.initSecretHash
source = "./modules/instance_group"
name = "${local.name}-1"
role = "Worker"
uid = local.uid
instance_type = var.instance_type
instance_count = var.worker_count
image_id = var.image_id
disk_size = var.state_disk_size
disk_type = var.state_disk_type
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_subnetwork_backend.id
alias_ip_range_name = google_compute_subnetwork.vpc_subnetwork.secondary_ip_range[0].range_name
kube_env = local.kube_env
debug = var.debug
labels = local.labels
init_secret_hash = local.initSecretHash
}
resource "google_compute_address" "loadbalancer_ip" {

View File

@ -56,7 +56,7 @@ resource "google_compute_instance_template" "template" {
subnetwork = var.subnetwork
alias_ip_range {
ip_cidr_range = "/24"
subnetwork_range_name = var.name
subnetwork_range_name = var.alias_ip_range_name
}
}

View File

@ -79,3 +79,8 @@ variable "debug" {
default = false
description = "Enable debug mode. This will enable serial port access on the instances."
}
variable "alias_ip_range_name" {
type = string
description = "Name of the alias IP range to use."
}