2024-05-23 08:47:29 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Controller node resources
|
|
|
|
#
|
|
|
|
|
2024-05-23 09:05:05 +00:00
|
|
|
resource "openstack_networking_port_v2" "kubecport" {
|
2024-05-23 08:47:29 +00:00
|
|
|
name = "${var.controller_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-port"
|
|
|
|
# We create as many ports as there are instances created
|
|
|
|
count = var.controller_instance_count
|
|
|
|
network_id = data.openstack_networking_network_v2.public.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.id,
|
2024-10-22 07:21:56 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-old.id,
|
2024-10-21 15:40:24 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-dco.id,
|
2024-06-04 11:53:57 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.https.id
|
2024-05-23 08:47:29 +00:00
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubecvolumeboot" {
|
|
|
|
count = var.controller_instance_count # size of cluster
|
|
|
|
name = "${var.controller_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-vol"
|
|
|
|
description = "OS volume for kubernetes control node ${count.index + 1}"
|
|
|
|
size = 100
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
}
|
|
|
|
|
2024-05-22 17:24:59 +00:00
|
|
|
resource "openstack_compute_instance_v2" "controller-nodes" {
|
|
|
|
count = var.controller_instance_count
|
2024-05-23 08:47:29 +00:00
|
|
|
name = "${var.controller_name}${count.index+1}.${var.dns_suffix}"
|
2024-05-22 17:24:59 +00:00
|
|
|
flavor_name = "${var.controller_instance_type}"
|
|
|
|
key_pair = "${var.keyname}"
|
2024-05-23 08:47:29 +00:00
|
|
|
security_groups = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.name,
|
2024-10-22 07:21:56 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-old.id,
|
2024-10-21 15:40:24 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-dco.id,
|
2024-06-04 11:53:57 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.https.name
|
2024-05-23 08:47:29 +00:00
|
|
|
]
|
2024-05-22 17:24:59 +00:00
|
|
|
block_device {
|
2024-05-23 08:47:29 +00:00
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubecvolumeboot[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
2024-05-22 17:24:59 +00:00
|
|
|
}
|
|
|
|
scheduler_hints {
|
|
|
|
group = openstack_compute_servergroup_v2.controllers.id
|
|
|
|
}
|
|
|
|
network {
|
2024-05-23 09:05:05 +00:00
|
|
|
port = resource.openstack_networking_port_v2.kubecport[count.index].id
|
2024-05-22 17:24:59 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-23 08:47:29 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Worker node resources
|
|
|
|
#
|
|
|
|
|
2024-05-23 09:05:05 +00:00
|
|
|
resource "openstack_networking_port_v2" "kubewport" {
|
|
|
|
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-port"
|
|
|
|
# We create as many ports as there are instances created
|
2024-10-15 12:52:52 +00:00
|
|
|
count = var.worker_instance_count
|
2024-05-23 09:05:05 +00:00
|
|
|
network_id = data.openstack_networking_network_v2.public.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.id,
|
2024-10-22 07:21:56 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-old.id
|
2024-05-23 09:05:05 +00:00
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubewvolumeboot" {
|
2024-10-15 12:52:52 +00:00
|
|
|
count = var.worker_instance_count # size of cluster
|
2024-05-23 09:05:05 +00:00
|
|
|
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-vol"
|
|
|
|
description = "OS volume for kubernetes worker node ${count.index + 1}"
|
|
|
|
size = 100
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
}
|
|
|
|
|
2024-10-15 12:52:52 +00:00
|
|
|
resource "openstack_blockstorage_volume_v3" "kubewvolumerook" {
|
|
|
|
count = var.worker_instance_count # size of cluster
|
|
|
|
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-rook-vol"
|
|
|
|
description = "Rook storage volume for kubernetes worker node ${count.index + 1}"
|
|
|
|
size = 100
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
}
|
|
|
|
|
2024-05-23 09:05:05 +00:00
|
|
|
|
2024-05-22 17:24:59 +00:00
|
|
|
resource "openstack_compute_instance_v2" "worker-nodes" {
|
|
|
|
count = var.worker_instance_count
|
2024-05-23 11:43:36 +00:00
|
|
|
name = "${var.worker_name}${count.index+1}.${var.dns_suffix}"
|
2024-05-22 17:24:59 +00:00
|
|
|
flavor_name = "${var.worker_instance_type}"
|
2024-10-15 13:38:44 +00:00
|
|
|
key_pair = "${var.keynameworkers}"
|
2024-05-23 09:05:05 +00:00
|
|
|
security_groups = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.name,
|
2024-10-22 07:21:56 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-old.name
|
2024-05-23 09:05:05 +00:00
|
|
|
]
|
2024-05-22 17:24:59 +00:00
|
|
|
|
|
|
|
block_device {
|
2024-05-23 09:05:05 +00:00
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumeboot[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
2024-05-22 17:24:59 +00:00
|
|
|
}
|
2024-10-15 12:52:52 +00:00
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumerook[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 1
|
|
|
|
}
|
|
|
|
|
2024-05-22 17:24:59 +00:00
|
|
|
scheduler_hints {
|
|
|
|
group = openstack_compute_servergroup_v2.workers.id
|
|
|
|
}
|
|
|
|
network {
|
2024-05-23 09:05:05 +00:00
|
|
|
port = resource.openstack_networking_port_v2.kubewport[count.index].id
|
2024-05-22 17:24:59 +00:00
|
|
|
}
|
|
|
|
}
|