diff --git a/infra.tf b/infra.tf index 49b16e6..6298541 100644 --- a/infra.tf +++ b/infra.tf @@ -1,15 +1,16 @@ module "infra" { source = "./modules/node-group" - region = var.region - role = "infra" - node_count = var.infra_count - node_name_suffix = local.node_name_suffix - image_slug = var.image_slug - flavor_slug = var.infra_flavor - volume_size_gb = var.default_volume_size_gb - subnet_uuid = local.subnet_uuid - ignition_ca = var.ignition_ca - api_int = "api-int.${local.node_name_suffix}" - cluster_id = var.cluster_id + region = var.region + role = "infra" + node_count = var.infra_count + node_name_suffix = local.node_name_suffix + image_slug = var.image_slug + flavor_slug = var.infra_flavor + volume_size_gb = var.default_volume_size_gb + subnet_uuid = local.subnet_uuid + ignition_ca = var.ignition_ca + api_int = "api-int.${local.node_name_suffix}" + cluster_id = var.cluster_id + make_adoptable_by_provider = var.make_worker_adoptable_by_provider } diff --git a/master.tf b/master.tf index 0f083f4..5a633c1 100644 --- a/master.tf +++ b/master.tf @@ -1,16 +1,17 @@ module "master" { source = "./modules/node-group" - region = var.region - role = "master" - ignition_config = "master" - node_count = var.master_count - node_name_suffix = local.node_name_suffix - image_slug = var.image_slug - flavor_slug = var.master_flavor - volume_size_gb = var.default_volume_size_gb - subnet_uuid = local.subnet_uuid - ignition_ca = var.ignition_ca - api_int = "api-int.${local.node_name_suffix}" - cluster_id = var.cluster_id + region = var.region + role = "master" + ignition_config = "master" + node_count = var.master_count + node_name_suffix = local.node_name_suffix + image_slug = var.image_slug + flavor_slug = var.master_flavor + volume_size_gb = var.default_volume_size_gb + subnet_uuid = local.subnet_uuid + ignition_ca = var.ignition_ca + api_int = "api-int.${local.node_name_suffix}" + cluster_id = var.cluster_id + make_adoptable_by_provider = var.make_master_adoptable_by_provider } diff --git a/modules/node-group/main.tf b/modules/node-group/main.tf index 5707ef9..34fc129 100644 --- a/modules/node-group/main.tf +++ b/modules/node-group/main.tf @@ -30,6 +30,12 @@ resource "cloudscale_server" "node" { subnet_uuid = var.subnet_uuid } } + + tags = var.make_adoptable_by_provider ? { + "machine-api-provider-cloudscale_appuio_io_name" : random_id.node[count.index].hex + } : { + } + user_data = <<-EOF { "ignition": { diff --git a/modules/node-group/variables.tf b/modules/node-group/variables.tf index c30deb5..53cfb28 100644 --- a/modules/node-group/variables.tf +++ b/modules/node-group/variables.tf @@ -60,3 +60,9 @@ variable "cluster_id" { type = string description = "ID of the cluster to which the nodes belong, used for rendering machines and machine sets" } + +variable "make_adoptable_by_provider" { + type = bool + description = "Whether to make the nodes adoptable by https://github.com/appuio/machine-api-provider-cloudscale" + default = false +} diff --git a/variables.tf b/variables.tf index f337af2..05151d8 100644 --- a/variables.tf +++ b/variables.tf @@ -205,3 +205,15 @@ variable "internal_router_vip" { description = "Custom internal floating IP for the router. Users must provide an IP that's within the final privnet CIDR." default = "" } + +variable "make_worker_adoptable_by_provider" { + type = bool + description = "Whether to make the worker nodes adoptable by https://github.com/appuio/machine-api-provider-cloudscale" + default = false +} + +variable "make_master_adoptable_by_provider" { + type = bool + description = "Whether to make the master nodes adoptable by https://github.com/appuio/machine-api-provider-cloudscale" + default = false +} diff --git a/worker.tf b/worker.tf index 1165af5..c09a4f0 100644 --- a/worker.tf +++ b/worker.tf @@ -1,17 +1,18 @@ module "worker" { source = "./modules/node-group" - region = var.region - role = "worker" - node_count = var.worker_count - node_name_suffix = local.node_name_suffix - image_slug = var.image_slug - flavor_slug = var.worker_flavor - volume_size_gb = local.worker_volume_size_gb - subnet_uuid = local.subnet_uuid - ignition_ca = var.ignition_ca - api_int = "api-int.${local.node_name_suffix}" - cluster_id = var.cluster_id + region = var.region + role = "worker" + node_count = var.worker_count + node_name_suffix = local.node_name_suffix + image_slug = var.image_slug + flavor_slug = var.worker_flavor + volume_size_gb = local.worker_volume_size_gb + subnet_uuid = local.subnet_uuid + ignition_ca = var.ignition_ca + api_int = "api-int.${local.node_name_suffix}" + cluster_id = var.cluster_id + make_adoptable_by_provider = var.make_worker_adoptable_by_provider } // Additional worker groups. @@ -21,15 +22,16 @@ module "additional_worker" { source = "./modules/node-group" - region = var.region - role = each.key - node_count = each.value.count - node_name_suffix = local.node_name_suffix - image_slug = var.image_slug - flavor_slug = each.value.flavor - volume_size_gb = each.value.volume_size_gb != null ? each.value.volume_size_gb : local.worker_volume_size_gb - subnet_uuid = local.subnet_uuid - ignition_ca = var.ignition_ca - api_int = "api-int.${local.node_name_suffix}" - cluster_id = var.cluster_id + region = var.region + role = each.key + node_count = each.value.count + node_name_suffix = local.node_name_suffix + image_slug = var.image_slug + flavor_slug = each.value.flavor + volume_size_gb = each.value.volume_size_gb != null ? each.value.volume_size_gb : local.worker_volume_size_gb + subnet_uuid = local.subnet_uuid + ignition_ca = var.ignition_ca + api_int = "api-int.${local.node_name_suffix}" + cluster_id = var.cluster_id + make_adoptable_by_provider = var.make_worker_adoptable_by_provider }