2024-10-18 11:59:55 +00:00
|
|
|
#
|
2024-10-22 05:09:07 +00:00
|
|
|
# Global definitions for sto4
|
2024-10-18 11:59:55 +00:00
|
|
|
#
|
|
|
|
locals {
|
2024-10-23 09:15:33 +00:00
|
|
|
sto4dc = "sto4"
|
|
|
|
sto4nodenrbase = index(var.datacenters, "sto4")
|
|
|
|
sto4indexjump = length(var.datacenters)
|
2024-10-18 11:59:55 +00:00
|
|
|
}
|
|
|
|
|
2024-10-22 05:09:07 +00:00
|
|
|
#
|
|
|
|
# Controller node resources
|
|
|
|
#
|
|
|
|
|
|
|
|
resource "openstack_networking_port_v2" "kubecport-sto4" {
|
2024-10-23 09:15:33 +00:00
|
|
|
name = "${var.controller_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto4dc}-port"
|
2024-10-22 05:09:07 +00:00
|
|
|
# We create as many ports as there are instances created
|
|
|
|
count = var.controllerdcreplicas
|
|
|
|
network_id = data.openstack_networking_network_v2.public-sto4.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto4.id,
|
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-sto4.id
|
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
provider = openstack.sto4
|
|
|
|
}
|
|
|
|
|
|
|
|
# Boot volume for node
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubecvolumeboot-sto4" {
|
2024-10-23 09:15:33 +00:00
|
|
|
count = var.controllerdcreplicas # Replicas per datacenter
|
|
|
|
name = "${var.controller_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto4dc}-vol"
|
|
|
|
description = "OS volume for kubernetes worker node ${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}"
|
2024-10-22 05:09:07 +00:00
|
|
|
size = 100
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image-sto4.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
provider = openstack.sto4
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_compute_instance_v2" "controller-nodes-sto4" {
|
|
|
|
count = var.controllerdcreplicas # Replicas per datacenter
|
2024-10-23 09:15:33 +00:00
|
|
|
name = "${var.controller_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}.${var.dns_suffix}"
|
2024-10-22 05:09:07 +00:00
|
|
|
flavor_name = "${var.controller_instance_type}"
|
|
|
|
key_pair = "${var.keynameworkers}"
|
|
|
|
provider = openstack.sto4
|
|
|
|
security_groups = [
|
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-sto4.name,
|
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto4.name
|
|
|
|
]
|
|
|
|
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubecvolumeboot-sto4[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
scheduler_hints {
|
|
|
|
group = openstack_compute_servergroup_v2.controllers-sto4.id
|
|
|
|
}
|
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.kubecport-sto4[count.index].id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Worker node resources
|
|
|
|
#
|
|
|
|
|
|
|
|
resource "openstack_networking_port_v2" "kubewport-sto4" {
|
2024-10-23 09:15:33 +00:00
|
|
|
name = "${var.worker_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto4dc}-port"
|
2024-10-18 11:59:55 +00:00
|
|
|
# We create as many ports as there are instances created
|
|
|
|
count = var.workerdcreplicas
|
|
|
|
network_id = data.openstack_networking_network_v2.public-sto4.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
2024-10-18 15:02:29 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto4.id,
|
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-sto4.id
|
2024-10-18 11:59:55 +00:00
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
provider = openstack.sto4
|
|
|
|
}
|
|
|
|
|
|
|
|
# Boot volume for node
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubewvolumeboot-sto4" {
|
|
|
|
count = var.workerdcreplicas # Replicas per datacenter
|
2024-10-23 09:15:33 +00:00
|
|
|
name = "${var.worker_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto4dc}-vol"
|
|
|
|
description = "OS volume for kubernetes worker node ${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}"
|
2024-10-18 11:59:55 +00:00
|
|
|
size = 100
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image-sto4.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
provider = openstack.sto4
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubewvolumerook-sto4" {
|
|
|
|
count = var.workerdcreplicas # Replicas per datacenter
|
2024-10-23 09:15:33 +00:00
|
|
|
name = "${var.worker_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto4dc}-rook-vol"
|
|
|
|
description = "Rook storage volume for kubernetes worker node ${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}"
|
2024-10-18 11:59:55 +00:00
|
|
|
size = 100
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
provider = openstack.sto4
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_compute_instance_v2" "worker-nodes-sto4" {
|
|
|
|
count = var.workerdcreplicas # Replicas per datacenter
|
2024-10-23 09:15:33 +00:00
|
|
|
name = "${var.worker_name}${count.index * local.sto4indexjump + 1 + local.sto4nodenrbase}.${var.dns_suffix}"
|
2024-10-18 11:59:55 +00:00
|
|
|
flavor_name = "${var.worker_instance_type}"
|
|
|
|
key_pair = "${var.keynameworkers}"
|
|
|
|
provider = openstack.sto4
|
|
|
|
security_groups = [
|
2024-10-18 15:02:29 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-sto4.name,
|
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto4.name
|
2024-10-18 11:59:55 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumeboot-sto4[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
|
|
|
}
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumerook-sto4[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
scheduler_hints {
|
|
|
|
group = openstack_compute_servergroup_v2.workers-sto4.id
|
|
|
|
}
|
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.kubewport-sto4[count.index].id
|
|
|
|
}
|
|
|
|
}
|