# # Global definitions sto3 # locals { sto3dc = "sto3" sto3nodenrbase = index(var.datacenters, "sto3") sto3indexjump = length(var.datacenters) } # # Control node resources STO3 # resource "openstack_networking_port_v2" "kubecport-sto3" { name = "${var.controller_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto3dc}-port" # We create as many ports as there are instances created count = var.controllerdcreplicas network_id = data.openstack_networking_network_v2.public-sto3.id # A list of security group ID security_group_ids = [ resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto3.id, resource.openstack_networking_secgroup_v2.microk8s-sto3.id, resource.openstack_networking_secgroup_v2.k8s-external-control-sto3.id ] admin_state_up = "true" provider = openstack.sto3 } # Boot volume for node resource "openstack_blockstorage_volume_v3" "kubecvolumeboot-sto3" { count = var.controllerdcreplicas # Replicas per datacenter name = "${var.controller_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto3dc}-vol" description = "OS volume for kubernetes worker node ${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}" size = 100 image_id = data.openstack_images_image_v2.debian12image-sto3.id enable_online_resize = true # Allow us to resize volume while attached. provider = openstack.sto3 } resource "openstack_compute_instance_v2" "controller-nodes-sto3" { count = var.controllerdcreplicas # Replicas per datacenter name = "${var.controller_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}.${var.dns_suffix}" flavor_name = "${var.controller_instance_type}" key_pair = "${var.keynameworkers}" provider = openstack.sto3 security_groups = [ resource.openstack_networking_secgroup_v2.microk8s-sto3.name, resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto3.name, resource.openstack_networking_secgroup_v2.k8s-external-control-sto3.name ] block_device { uuid = resource.openstack_blockstorage_volume_v3.kubecvolumeboot-sto3[count.index].id source_type = "volume" destination_type = "volume" boot_index = 0 } scheduler_hints { group = openstack_compute_servergroup_v2.controllers-sto3.id } network { port = resource.openstack_networking_port_v2.kubecport-sto3[count.index].id } } # # Worker node resources STO3 # resource "openstack_networking_port_v2" "kubewport-sto3" { name = "${var.worker_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto3dc}-port" # We create as many ports as there are instances created count = var.workerdcreplicas network_id = data.openstack_networking_network_v2.public-sto3.id # A list of security group ID security_group_ids = [ resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto3.id, resource.openstack_networking_secgroup_v2.microk8s-sto3.id ] admin_state_up = "true" provider = openstack.sto3 } # Boot volume for node resource "openstack_blockstorage_volume_v3" "kubewvolumeboot-sto3" { count = var.workerdcreplicas # Replicas per datacenter name = "${var.worker_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto3dc}-vol" description = "OS volume for kubernetes worker node ${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}" size = 100 image_id = data.openstack_images_image_v2.debian12image-sto3.id enable_online_resize = true # Allow us to resize volume while attached. provider = openstack.sto3 } resource "openstack_blockstorage_volume_v3" "kubewvolumerook-sto3" { count = var.workerdcreplicas # Replicas per datacenter name = "${var.worker_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.sto3dc}-rook-vol" description = "Rook storage volume for kubernetes worker node ${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}" size = 100 enable_online_resize = true # Allow us to resize volume while attached. provider = openstack.sto3 } resource "openstack_compute_instance_v2" "worker-nodes-sto3" { count = var.workerdcreplicas # Replicas per datacenter name = "${var.worker_name}${count.index * local.sto3indexjump + 1 + local.sto3nodenrbase}.${var.dns_suffix}" flavor_name = "${var.worker_instance_type}" key_pair = "${var.keynameworkers}" provider = openstack.sto3 security_groups = [ resource.openstack_networking_secgroup_v2.microk8s-sto3.name, resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto3.name ] block_device { uuid = resource.openstack_blockstorage_volume_v3.kubewvolumeboot-sto3[count.index].id source_type = "volume" destination_type = "volume" boot_index = 0 } block_device { uuid = resource.openstack_blockstorage_volume_v3.kubewvolumerook-sto3[count.index].id source_type = "volume" destination_type = "volume" boot_index = 1 } scheduler_hints { group = openstack_compute_servergroup_v2.workers-sto3.id } network { port = resource.openstack_networking_port_v2.kubewport-sto3[count.index].id } }