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